I’m exploring Examples from swift-models repository, particularly trying to run Mobilenet-Imagenette on Google Colab. I just opened a blank notebook as mentioned on tensorflow/swift repo and haven’t installed any packages.
What are the necessary steps I should follow to start using swift-models on colab? As I can see from many notebooks, there are some initial %install '.package...' commands.
Without any installation, trying to run following code throws error: use of unresolved identifier for ImagenetteBatchers
bradlarson
(Brad Larson (formerly Swift for TensorFlow))
2
To install the necessary packages, we have some specific commands that must be run in the very first cell before any other Swift code has been executed (if it has, restart your kernel to make sure it runs first). For running MobileNet with Imagenette, I believe you’ll need the following:
which will grab and build the Datasets and ImageClassificationModels modules from swift-models and make them ready for use in the remaining notebook. You can then run the remainder of your code.
There are many examples of this in notebooks, but one I can think of right now is the FastStyleTransfer notebook demo project that was contributed to swift-models recently.
Speaking of Colab, we’re about to roll out the 0.8 toolchain to Colab and will have some exciting announcements at the March 20 Swift for TensorFlow open design meeting, so make sure to sign up to the mailing list to get the public meeting invitation.
Thanks! Now I got to know how to install dependencies. However, it seems like there are some issues with ImageClassificationModels. While installing the same, it caused following error:
/content/swift-packages/package/.build/checkouts/swift-models/Models/ImageClassification/ResNet.swift:36:99: error: extra argument 'useBias' in call
self.conv = Conv2D(filterShape: filterShape, strides: strides, padding: padding, useBias: false)
^~~~~
/content/swift-packages/package/.build/checkouts/swift-models/Models/ImageClassification/ResNetV2.swift:44:22: error: extra argument 'useBias' in call
useBias: false)
^~~~~
[2/55] Compiling SwiftProtobuf BinaryDecoder.swift
/content/swift-packages/package/.build/checkouts/swift-models/Models/ImageClassification/ResNet.swift:36:99: error: extra argument 'useBias' in call
self.conv = Conv2D(filterShape: filterShape, strides: strides, padding: padding, useBias: false)
^~~~~
/content/swift-packages/package/.build/checkouts/swift-models/Models/ImageClassification/ResNetV2.swift:44:22: error: extra argument 'useBias' in call
useBias: false)
^~~~~
[3/55] Compiling SwiftProtobuf BinaryDecodingError.swift
/content/swift-packages/package/.build/checkouts/swift-models/Models/ImageClassification/ResNet.swift:36:99: error: extra argument 'useBias' in call
self.conv = Conv2D(filterShape: filterShape, strides: strides, padding: padding, useBias: false)
^~~~~
/content/swift-packages/package/.build/checkouts/swift-models/Models/ImageClassification/ResNetV2.swift:44:22: error: extra argument 'useBias' in call
useBias: false)
^~~~~
[4/55] Compiling SwiftProtobuf BinaryDecodingOptions.swift
/content/swift-packages/package/.build/checkouts/swift-models/Models/ImageClassification/ResNet.swift:36:99: error: extra argument 'useBias' in call
self.conv = Conv2D(filterShape: filterShape, strides: strides, padding: padding, useBias: false)
^~~~~
/content/swift-packages/package/.build/checkouts/swift-models/Models/ImageClassification/ResNetV2.swift:44:22: error: extra argument 'useBias' in call
useBias: false)
Should I open an issue for this?
So excited for this one, guessing it could be the ability of creating new swift notebooks directly from Colab.
Not sure, maybe @bradlarson can tell us. But once the 0.8 release is there, this code will work.
bradlarson
(Brad Larson (formerly Swift for TensorFlow))
7
As Sylvain said, this is due to recent changes in the swift-apis that made bias optional for convolution layers. This was recently updated in the ImageClassificationModels at head, because we expect that Colab will be migrated to version 0.8 of the toolchain within the next few days. When Colab is running 0.8, we’ll announce it in the mailing list.
If you still want to experiment with the models in Colab before the toolchain is updated, you can change .branch("master") in the above to .branch("tensorflow-0.7"). It won’t have all the updates in the 0.7->0.8 period, but should work just fine with the 0.7 toolchain in Colab.
Regarding creating Swift notebooks directly from Colab, they recently added the ability to use the link https://colab.research.google.com/notebook#create=true&language=swift to create blank Swift notebooks. Support in the Colab creation menu is still being worked on, to my understanding.
when i try to run course-v3 (swift) using colab I’ve got this error
unrecognized runtime “swift”; defaulting to “python3”.
please help me to get the solution
bradlarson
(Brad Larson (formerly Swift for TensorFlow))
9
Unfortunately, as a consequence of investment in Swift for TensorFlow winding down at Google, Colab no longer supports running Swift code. I’m sorry about that, I know it was an extremely convenient way to experiment with differentiable Swift on accelerators.