Adagrad constructor
Implementation
Adagrad(
super.parameters, {
required super.learningRate,
this.epsilon = 1e-8,
}) {
_gSquaredSum = {};
for (Tensor param in parameters) {
if (param.value is Vector) {
_gSquaredSum[param] = List<double>.filled((param.value as Vector).length, 0.0);
} else if (param.value is Matrix) {
Matrix sumMatrix = [];
int numRows = (param.value as Matrix).length;
int numCols = numRows > 0 ? (param.value as Matrix)[0].length : 0;
for (int i = 0; i < numRows; i++) {
sumMatrix.add(List<double>.filled(numCols, 0.0));
}
_gSquaredSum[param] = sumMatrix;
}
}
}