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

Method forward

python/singa/layer.py:1185–1201  ·  view source on GitHub ↗
(self, xs, h0)

Source from the content-addressed store, hash-verified

1183 self.b.set_value(0.0)
1184
1185 def forward(self, xs, h0):
1186 # xs: a tuple or list of input tensors
1187 if not isinstance(xs, tuple):
1188 xs = tuple(xs)
1189 inputs = xs + (h0,)
1190 self.device_check(*inputs)
1191 # self.device_check(inputs[0], *self.params)
1192 self.device_check(inputs[0], self.Wx, self.Wh, self.b)
1193 batchsize = xs[0].shape[0]
1194 out = []
1195 h = self.step_forward(xs[0], h0, self.Wx, self.Wh, self.b)
1196 out.append(h)
1197 for x in xs[1:]:
1198 assert x.shape[0] == batchsize
1199 h = self.step_forward(x, h, self.Wx, self.Wh, self.b)
1200 out.append(h)
1201 return out, h
1202
1203 def step_forward(self, x, h, Wx, Wh, b):
1204 y2 = autograd.matmul(h, Wh)

Callers

nothing calls this directly

Calls 4

step_forwardMethod · 0.95
appendMethod · 0.80
tupleFunction · 0.50
device_checkMethod · 0.45

Tested by

no test coverage detected