You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 1, 2023. It is now read-only.
Reduce explicit types required when instantiating the SGD optimizer. (#28)
Previously, in order to instantiate the Optimizer, you had to call
`type(of: model)` and pass that into the Optimizer constructor in order to get
type inference to pick the right type for `Model`. This could be a little
confusing for new users.
This commit proposes an alternate way to write this:
```swift
let optimizer = SGD(for: model, learningRate: 0.01, scalarType: Float.self)
```
The above formulation is clear and readable. It avoids any unnecessary typing
of generic argument types.
By annotating the model parameter as `__shared`, we ensure that we don't pay
for the cost of a model copy (which could eventually be very expensive).
0 commit comments