I tried to define a generic Adam optimizer using ElementaryFunctions
, Differentiable
, and VectorProtocol
(latter two are being incubated on tensorflow
branch).
It doesn't work due to missing scalar-vector and vector-vector operations.
$ swift adam.swift
adam.swift:82:95: error: binary operator '+' cannot be applied to operands of type 'Model.TangentVector' and 'Model.TangentVector.VectorSpaceScalar'
model.move(along: -stepSize * firstMoments / (Model.TangentVector.sqrt(secondMoments) + epsilon))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~
adam.swift:82:95: note: expected an argument list of type '(Self, Self)'
model.move(along: -stepSize * firstMoments / (Model.TangentVector.sqrt(secondMoments) + epsilon))
^
There's another unhandled /(Model, Model)
operation on line 82:
model.move(along: -stepSize * firstMoments / (Model.TangentVector.sqrt(secondMoments) + epsilon))
~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$ swift --version
Apple Swift version 5.1-dev (LLVM 082dec2e22, Swift fc0ab61888)
Target: x86_64-apple-darwin18.6.0