def __call__(self, value): # check type if isinstance(value, ArrayType): pass elif isinstance(value, (tuple,list)): value = array(value) else: raise TypeError("pArray data must be of type array/tuple/list.") # check rank if rank(value) != self._rank: raise TypeError("pArray data must be of rank %d but it is %d." % (_rank, rank(value))) return value
def learn_step(self, input, output): if rank(input) == 1: input = reshape(input, (len(input), 1)) X = join((input, [[1]])) self._fn.learn_step(X, output)
def learn_step(self, input, output): if rank(input) == 1: input = reshape(input, (self.num_inputs, 1)) if rank(output) == 1: output = reshape(output, (self.num_outputs, 1)) result = self(input) err = output - result self.MSE = norm(err.flat**2) / self.num_outputs self.debug("MSE =", self.MSE) alpha = self.alpha / sum(input**2) self.w += alpha * transpose(dot(input, transpose(err))) self.debug("update ratio =", norm(self(input) - result) / norm(err))
def learn_step(self,input,output): if rank(input) == 1: input = reshape(input,(len(input),1)) X = join((input,[[1]])) self._fn.learn_step(X,output)
def learn_step(self,input,output): if rank(input) == 1: input = reshape(input,(self.num_inputs,1)) if rank(output) == 1: output = reshape(output,(self.num_outputs,1)) result = self(input) err = output - result self.MSE = norm(err.flat**2)/self.num_outputs self.debug("MSE =",self.MSE) alpha = self.alpha/sum(input**2) self.w += alpha*transpose(dot(input,transpose(err))) self.debug( "update ratio =", norm(self(input)-result)/norm(err))
def __call__(self, input, error=False): if rank(input) == 1: X = join((input, [1])) else: X = join((input, [[1]])) return self._fn(X, error=error)
def __call__(self,input,error=False): if rank(input) == 1: X = join((input,[1])) else: X = join((input,[[1]])) return self._fn(X,error=error)