Minor bug in 09_optimizer

I think this cell in 09_optimizer

public extension StatefulOptimizer {
    func setParam(_ hp: String, _ val: Float) {
        for i in 0..<configs.count { configs[i][hp] = val }
    }
}

needs an //export. I was otherwise unable to build 11_imagenette or import 09_optimizer into my own nb, as it was failing with an error saying “StatefulOptimizer has no member setParam” or similar (I forgot to save the actual error text).

As an aside, I couldn’t get the notebook to recompile properly, either; I ran notebookToScript(fname: Path.cwd / "09_optimizer.ipynb") and then exportNotebooks(Path.cwd) but it didn’t seem to update the package. I had to manually write the above extension into FastaiNotebook_09_optimizer/Sources/FastaiNotebook_09_optimizer/09_optimizer.swift to get that module to import.

Sorry if this is already fixed and/or I’m missing something stupid (again).

1 Like

Way ahead of you, it has been fixed in this commit :wink:

Also, once you have run the line notebookToScript you need to recreate the packages with the python script create_packages.py.

1 Like

Which is obviously not ideal - but hopefully @pcuenq will create something better! :slight_smile:

I should learn that (especially!) on lesson days, a git pull every hour isn’t enough :wink: Thanks!

2 Likes

The Swift notebook exporter is now ready for testing. Please, use version 0.2.0 or the fastai branch. I wrote some brief instructions in the readme file, but anyone wanting to give it a go, please feel free to ping me!

2 Likes