MCPcopy Index your code
hub / github.com/ddbourgin/numpy-ml / __init__

Method __init__

numpy_ml/neural_nets/layers/layers.py:366–410  ·  view source on GitHub ↗

A Restricted Boltzmann machine with Bernoulli visible and hidden units. Parameters ---------- n_out : int The number of output dimensions/units. K : int The number of contrastive divergence steps to run before computing a

(self, n_out, K=1, init="glorot_uniform", optimizer=None)

Source from the content-addressed store, hash-verified

364
365class RBM(LayerBase):
366 def __init__(self, n_out, K=1, init="glorot_uniform", optimizer=None):
367 """
368 A Restricted Boltzmann machine with Bernoulli visible and hidden units.
369
370 Parameters
371 ----------
372 n_out : int
373 The number of output dimensions/units.
374 K : int
375 The number of contrastive divergence steps to run before computing
376 a single gradient update. Default is 1.
377 init : {'glorot_normal', 'glorot_uniform', 'he_normal', 'he_uniform'}
378 The weight initialization strategy. Default is `'glorot_uniform'`.
379 optimizer : str, :doc:`Optimizer <numpy_ml.neural_nets.optimizers>` object, or None
380 The optimization strategy to use when performing gradient updates
381 within the :meth:`update` method. If None, use the :class:`SGD
382 <numpy_ml.neural_nets.optimizers.SGD>` optimizer with
383 default parameters. Default is None.
384
385 Attributes
386 ----------
387 X : list
388 Unused
389 gradients : dict
390 Dictionary of loss gradients with regard to the layer parameters
391 parameters : dict
392 Dictionary of layer parameters
393 hyperparameters : dict
394 Dictionary of layer hyperparameters
395 derived_variables : dict
396 Dictionary of any intermediate values computed during
397 forward/backward propagation.
398 """ # noqa: E501
399 super().__init__(optimizer)
400
401 self.K = K # CD-K
402 self.init = init
403 self.n_in = None
404 self.n_out = n_out
405 self.is_initialized = False
406 self.act_fn_V = ActivationInitializer("Sigmoid")()
407 self.act_fn_H = ActivationInitializer("Sigmoid")()
408 self.parameters = {"W": None, "b_in": None, "b_out": None}
409
410 self._init_params()
411
412 def _init_params(self):
413 init_weights = WeightInitializer(str(self.act_fn_V), mode=self.init)

Callers 15

__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45

Calls 2

_init_paramsMethod · 0.95

Tested by

no test coverage detected