-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from qoncept/dev-0.2.3
Update for Swift 4
- Loading branch information
Showing
42 changed files
with
269 additions
and
443 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,28 @@ | ||
// swift-tools-version:4.0 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "TensorSwift" | ||
name: "TensorSwift", | ||
products: [ | ||
// Products define the executables and libraries produced by a package, and make them visible to other packages. | ||
.library( | ||
name: "TensorSwift", | ||
targets: ["TensorSwift"]), | ||
], | ||
dependencies: [ | ||
// Dependencies declare other packages that this package depends on. | ||
// .package(url: /* package url */, from: "1.0.0"), | ||
], | ||
targets: [ | ||
// Targets are the basic building blocks of a package. A target can define a module or a test suite. | ||
// Targets can depend on other targets in this package, and on products in packages which this package depends on. | ||
.target( | ||
name: "TensorSwift", | ||
dependencies: []), | ||
.testTarget( | ||
name: "TensorSwiftTests", | ||
dependencies: ["TensorSwift"]), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# TensorSwift | ||
|
||
_TensorSwift_ is a lightweight library to calculate tensors, which has similar APIs to [_TensorFlow_](https://www.tensorflow.org/)'s. _TensorSwift_ is useful to simulate calculating tensors in Swift __using models trained by _TensorFlow___. | ||
_TensorSwift_ is a lightweight library to calculate tensors, which has similar APIs to [_TensorFlow_](https://www.tensorflow.org/)'s. _TensorSwift_ is useful to simulate calculating tensors in Swift **using models trained by _TensorFlow_**. | ||
|
||
```swift | ||
let a = Tensor(shape: [2, 3], elements: [1, 2, 3, 4, 5, 6]) | ||
|
@@ -31,15 +31,15 @@ public struct Classifier { | |
public let b_fc1: Tensor | ||
public let W_fc2: Tensor | ||
public let b_fc2: Tensor | ||
|
||
public func classify(x_image: Tensor) -> Int { | ||
public func classify(_ x_image: Tensor) -> Int { | ||
let h_conv1 = (x_image.conv2d(filter: W_conv1, strides: [1, 1, 1]) + b_conv1).relu() | ||
let h_pool1 = h_conv1.maxPool(kernelSize: [2, 2, 1], strides: [2, 2, 1]) | ||
|
||
let h_conv2 = (h_pool1.conv2d(filter: W_conv2, strides: [1, 1, 1]) + b_conv2).relu() | ||
let h_pool2 = h_conv2.maxPool(kernelSize: [2, 2, 1], strides: [2, 2, 1]) | ||
|
||
let h_pool2_flat = h_pool2.reshaped([1, 7 * 7 * 64]) | ||
let h_pool2_flat = h_pool2.reshaped([1, Dimension(7 * 7 * 64)]) | ||
let h_fc1 = (h_pool2_flat.matmul(W_fc1) + b_fc1).relu() | ||
|
||
let y_conv = (h_fc1.matmul(W_fc2) + b_fc2).softmax() | ||
|
@@ -54,7 +54,7 @@ public struct Classifier { | |
### Swift Package Manager | ||
|
||
```swift | ||
.Package(url: "[email protected]:qoncept/TensorSwift.git", majorVersion: 0, minor: 2), | ||
.Package(url: "[email protected]:qoncept/TensorSwift.git", from: "0.2.0"), | ||
``` | ||
|
||
### CocoaPods | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.