def __init__(self, ci, cn, transf, max_iter, delta): Layer.__init__(self, ci, cn, cn, {'w': (cn, ci), 'b': cn}) self.max_iter = max_iter self.delta = delta self.transf = transf self.outs = [] if not hasattr(transf, 'out_minmax'): test = np.asfarry([-1e100, -100, -10, -1, 0, 1, 10, 100, 1e100]) val = self.transf(test) self.out_minmax = np.array([val.min(), val.max()] * self.co) else: self.out_minmax = np.asfarray([transf.out_minmax] * self.co) self.initf = None self.s = np.zeros(self.cn)
def __init__(self, ci, cn, transf): Layer.__init__(self, ci, cn, cn, {'w':(cn, ci), 'b': cn}) self.transf = transf if not hasattr(transf, 'out_minmax'): Inf = 1e100 self.out_minmax = np.array([(self.transf(-Inf), self.transf(Inf))] * self.co) else: self.out_minmax = np.array([np.asfarray(transf.out_minmax)] * self.co) # default init function self.initf = init.initwb_reg self.s = np.zeros(self.cn)
def __init__(self, ci, cn, transf): Layer.__init__(self, ci, cn, cn, {'w': (cn, ci), 'b': cn}) self.transf = transf if not hasattr(transf, 'out_minmax'): test = np.asfarry([-1e100, -100, -10, -1, 0, 1, 10, 100, 1e100]) val = self.transf(test) self.out_minmax = np.array([val.min(), val.max()] * self.co) else: self.out_minmax = np.asfarray([transf.out_minmax] * self.co) # default init function self.initf = init.initwb_reg #self.initf = init.initwb_nw self.s = np.zeros(self.cn)
def __init__(self, ci, cn, distf=None): Layer.__init__(self, ci, cn, cn, {'w': (cn, ci), 'conscience': cn}) self.transf = trans.Competitive() self.initf = init.midpoint self.out_minmax[:] = np.array([self.transf.out_minmax] * cn) self.np['conscience'].fill(1.0) def euclidean(A, B): """ Euclidean distance function. See scipi.spatial.distance.cdist() :Example: >>> import numpy as np >>> euclidean(np.array([0,0]), np.array([[0,1], [0, 5.5]])).tolist() [1.0, 5.5] """ return np.sqrt(np.sum(np.square(A-B) ,axis=1)) self.distf = euclidean
def __init__(self, ci, cb, transf, cbo=1, shift=1): Layer.__init__(self, ci, cn, cn, {'w': (cn, cb), 'b': cn}) self.cb = cb self.shift = shift self.transf = transf