MCPcopy Create free account
hub / github.com/apache/singa / initialize

Method initialize

python/singa/layer.py:314–333  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

312 self.bias = bias
313
314 def initialize(self, x):
315 self.in_features = x.shape[1]
316 w_shape = (self.in_features, self.out_features)
317 b_shape = (self.out_features,)
318
319 self.W = Tensor(shape=w_shape,
320 dtype=x.dtype,
321 requires_grad=True,
322 stores_grad=True)
323 std = math.sqrt(2.0 / (self.in_features + self.out_features))
324 self.W.gaussian(0.0, std)
325
326 if self.bias:
327 self.b = Tensor(shape=b_shape,
328 dtype=x.dtype,
329 requires_grad=True,
330 stores_grad=True)
331 self.b.set_value(0.0)
332 else:
333 self.b = None
334
335 def forward(self, x):
336 if self.b:

Callers

nothing calls this directly

Calls 3

TensorClass · 0.70
gaussianMethod · 0.45
set_valueMethod · 0.45

Tested by

no test coverage detected