private StringKeyedVector n = new StringKeyedVector();
@Override
public StringKeyedVector getUpdate(LabeledInstance<L> instance) {
FTRLRegularization(instance);
StringKeyedVector gradients = model.getGradients(instance);
Iterator<Map.Entry<String, Double>> it = gradients.iterator();
while (it.hasNext()) {
Map.Entry<String,Double> pairs = (Map.Entry)it.next();
String feature = pairs.getKey();
double gradient = pairs.getValue();
double eta = getFeatureLearningRate(feature, gradient);
double z_i = 0.0; // if first round, set z_i to 0.0
if (z.containsKey(feature)) {
z_i = z.getCoordinate(feature);
}
double update = (z_i + gradient) - eta * model.param.getCoordinate(feature);
z.setCoordinate(feature, update);
double n_i = 0.0; // if first round, set n_i to 0.0
if (n.containsKey(feature)) {
n_i = n.getCoordinate(feature);
}
n.setCoordinate(feature, n_i + gradient * gradient);
}
return new StringKeyedVector(); // Model updates happen in the FTRLRegularization step
}