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

Method _init_params

numpy_ml/neural_nets/layers/layers.py:2421–2435  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2419 self.is_initialized = False
2420
2421 def _init_params(self):
2422 init_weights = WeightInitializer(str(self.act_fn), mode=self.init)
2423
2424 b = np.zeros((1, self.n_out))
2425 W = init_weights((self.n_in, self.n_out))
2426
2427 # convert a fully connected base layer into a sparse layer
2428 n_in, n_out = W.shape
2429 p = (self.epsilon * (n_in + n_out)) / (n_in * n_out)
2430 mask = np.random.binomial(1, p, shape=W.shape)
2431
2432 self.derived_variables = {"Z": []}
2433 self.parameters = {"W": W, "b": b, "W_mask": mask}
2434 self.gradients = {"W": np.zeros_like(W), "b": np.zeros_like(b)}
2435 self.is_initialized = True
2436
2437 @property
2438 def hyperparameters(self):

Callers 1

forwardMethod · 0.95

Calls 1

WeightInitializerClass · 0.85

Tested by

no test coverage detected