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

Method initialize

examples/trans/model.py:571–590  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

569 self.bias = bias
570
571 def initialize(self, x):
572 self.in_features = x.shape[-1]
573 w_shape = (self.in_features, self.out_features)
574 b_shape = (self.out_features,)
575
576 self.W = Tensor(shape=w_shape,
577 dtype=x.dtype,
578 requires_grad=True,
579 stores_grad=True)
580 std = math.sqrt(2.0 / (self.in_features + self.out_features))
581 self.W.gaussian(0.0, std)
582
583 if self.bias:
584 self.b = Tensor(shape=b_shape,
585 dtype=x.dtype,
586 requires_grad=True,
587 stores_grad=True)
588 self.b.set_value(0.0)
589 else:
590 self.b = None
591
592 def forward(self, x):
593 if self.b:

Callers 2

forwardMethod · 0.45
forwardMethod · 0.45

Calls 3

TensorClass · 0.90
gaussianMethod · 0.45
set_valueMethod · 0.45

Tested by

no test coverage detected