def __init__(self, sample, **kwargs): r""" See ``RosenblattPerceptronAlgorithm`` for full definition. """ PerceptronAlgorithm.__init__(self, sample, **kwargs) IterativeAlgorithm.__init__(self, sample) PerceptronAlgorithm.reset(self, **kwargs)
def __init__(self, sample, **kwargs): r""" See ``GradientPerceptronAlgorithm`` for full documentation. """ PerceptronAlgorithm.__init__(self, sample, **kwargs) IterativeAlgorithm.__init__(self, sample) # This calms down pylint self.beta = None self.reset(**kwargs)
def __init__(self, sample, n_clusters = 2, m = 2, **kwargs ): IterativeAlgorithm.__init__(self, sample) try: self.initializer = kwargs['initializer'] except KeyError: self.initializer = False self.n_clusters = n_clusters self.m = m self.distance = 1.0 #self.reset(**kwargs) self.memberships_old = None self.reset(**kwargs)
def __init__(self, sample, dimensions=None, **kwargs): r""" See ``BackpropagationAlgorithm`` for full documentation. """ IterativeAlgorithm.__init__(self, sample) # dimensions needs to be a named argument in order to be able to # cross-validate on it. The default value will correspond to three # layers, with the input and output one automatically sized in order # to fit the provided data set, and the hidden one containing half of # the biggest value between number of input and output units. if dimensions is not None: self.dimensions = dimensions else: n_in = len(sample[0].pattern) n_out = len(sample[0].label) self.dimensions = (n_in, int(max(n_in, n_out) / 2), n_out) num_input = self.dimensions[0] for example in sample: if len(example.pattern) != num_input: raise ValueError('Sample incompatible with number of units') try: self.activations = kwargs['activations'] if len(self.activations) != len(dimensions): raise ValueError(\ 'Activations incompatible with number of layers') except KeyError: self.activations = SigmoidActivationFunction() except TypeError: pass # Raised by len if the argument is assigned a single activation # this calms down pylint self.threshold = None self.reset(**kwargs)