1 """
2 This module contains ell2 ball constraint avg function.
3 """
4
5 import victor_utils
6
8 """
9 Calculates ell2 ball constraint avg
10 @type w: vector
11 @param w: model vector
12 @type x: vector
13 @param x: feature vector of the example
14 @type y: number
15 @param y: label of the example
16 @type stepsize: double
17 @param stepsize: step size
18 @type w_hat: vector
19 @param w_hat: w hat
20 @type steps: number
21 @param steps: number of steps
22 """
23 wx = victor_util.dot(w, x)
24 err = (wx - y)
25 etd = - stepsize * err
26 victor_util.add_and_scale(w, wx, etd)
27 victor_util.incremental_average(w_hat, w, steps)
28