         let learningRate = self.learningRate * 1 / (1 + decay * step)
         for kp in model.recursivelyAllWritableKeyPaths(to: Tensor<Scalar>.self) {
             alpha[keyPath: kp] =
-                rho * alpha[keyPath: kp] + (1 - rho) * pow(gradient[keyPath: kp], 2)
+                rho * alpha[keyPath: kp] + (1 - rho) * pow(vector[keyPath: kp], 2)
             model[keyPath: kp] -=
-                learningRate * gradient[keyPath: kp] / (sqrt(alpha[keyPath: kp]) + epsilon)
+                learningRate * vector[keyPath: kp] / (sqrt(alpha[keyPath: kp]) + epsilon)
         }
     }
 }

    private var velocity = Model.AllDifferentiableVariables.zero

    public func update(_ model: inout Model.AllDifferentiableVariables,
                       along vectors: Model.CotangentVector) {
        step += 1
        let learningRate = self.learningRate * 1 / (1 + decay * step)
        for kp in model.recursivelyAllWritableKeyPaths(to: Tensor<Scalar>.self) {
            velocity[keyPath: kp] =
                momentum * velocity[keyPath: kp] - learningRate * gradients[keyPath: kp]
            if nesterov {
                model[keyPath: kp] +=
                    momentum * velocity[keyPath: kp] - learningRate * gradients[keyPath: kp]
            } else {
                model[keyPath: kp] += velocity[keyPath: kp]
            }


    public func update(_ model: inout Model.AllDifferentiableVariables,
                       along vector: Model.CotangentVector) {
        model = model.moved(along: learningRate * (.zero - model.tangentVector(from: vector)))
    }
}
