def init(self): naxes = len(self.out_shape) if naxes == 2 or naxes == 4: dim = self.out_shape[1] elif naxes == 3: dim = self.out_shape[-1] else: raise NotImplementedError self.g = inits.Constant(c=1.)(dim) self.b = inits.Constant(c=0.)(dim) self.u = inits.Constant(c=0.)(dim) self.s = inits.Constant(c=0.)(dim) self.n = sharedX(0.) self.params = [self.g, self.b] self.other_params = [self.u, self.s, self.n]
def __init__(self, activation, init_fn=inits.Constant(c=0.25), update_fn='nag'): self.activation = instantiate(activations, activation) self.init_fn = instantiate(inits, init_fn) self.update_fn = instantiate(updates, update_fn)
h = leakyrectify(scale_and_shift(T.dot(X, w), g, b)) h2 = leakyrectify(scale_and_shift(T.dot(h, w2), g2, b2)) y = T.dot(h2, wo) return y def d(X, w, g, b, w2, g2, b2, wo): h = rectify(scale_and_shift(T.dot(X, w), g, b)) h2 = tanh(scale_and_shift(T.dot(h, w2), g2, b2)) y = sigmoid(T.dot(h2, wo)) return y #initialize both networks gw = init_fn((1, nh)) gg = inits.Constant(1.)(nh) gg = inits.Normal(1., 0.02)(nh) gb = inits.Normal(0., 0.02)(nh) gw2 = init_fn((nh, nh)) gg2 = inits.Normal(1., 0.02)(nh) gb2 = inits.Normal(0., 0.02)(nh) gy = init_fn((nh, 1)) ggy = inits.Constant(1.)(1) gby = inits.Normal(0., 0.02)(1) dw = init_fn((1, nh)) dg = inits.Normal(1., 0.02)(nh) db = inits.Normal(0., 0.02)(nh) dw2 = init_fn((nh, nh)) dg2 = inits.Normal(1., 0.02)(nh) db2 = inits.Normal(0., 0.02)(nh) dy = init_fn((nh, 1))