Giter Site home page Giter Site logo

Comments (3)

brettkoonce avatar brettkoonce commented on August 21, 2024 1

working here, have trained a resnet50 model using checkpoints, thanks again for the notes!

from swift-models.

BradLarson avatar BradLarson commented on August 21, 2024

This is due to a shortcoming in the current checkpoint reader's iteration implementation. When I first put this together, there wasn't a way to use reflection to determine if a property was writeable, so it was possible to have the reflection part of the iteration find a path that shouldn't be part of the checkpoint. As a hacky way around this, I let you specify properties that you can ignore for reading and writing via ignoredTensorPaths in the Checkpointable protocol.

In the case of ResNet (and anything else that uses BatchNorm), inside of BatchNorm are the properties runningMean and runningVariance that are not to be used inside a checkpoint. You need to manually ignore these by adjusting the conformance to

extension ResNet: Checkpointable {
  public var ignoredTensorPaths: Set<String> {
    return ["BatchNorm<Float>.runningMean", "BatchNorm<Float>.runningVariance"]
  }
}

The good news is that the new reflection enhancements upstream will allow for immutable properties to be determined, and this workaround can go away. However, because that's not supported in all of our toolchains, I held off on reworking this to use that interface.

Additionally, there's also a current flaw in the checkpoint reading where you'll need to change your code above to read

try model.readCheckpoint(from: temporaryDirectory.appendingPathComponent("ResNet"), name: "ResNet")

for it to find the written checkpoint. I need to align the directory naming between reading and writing checkpoints to do away with this inconsistency. Sorry about the implementation flaws here.

from swift-models.

brettkoonce avatar brettkoonce commented on August 21, 2024

@BradLarson thanks for the notes, that works here!

from swift-models.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.