def create_convolution(size, depth, winlen): conv_actfun = activation.tanh return layers.Serial( [layers.Convolution(3, size, winlen, stride=1, fun=conv_actfun)] + [layers.Residual(layers.Convolution(size, size, winlen, stride=1, fun=conv_actfun)) for _ in range(depth)] + [layers.Convolution(size, 3, winlen, stride=1, fun=activation.linear)] )
def test_003_simple_serial(self): W2 = np.random.normal(size=(self._SIZE, self._SIZE)).astype(taiyaki_dtype) res = self.res.dot(W2.transpose()) l1 = nn.FeedForward(self._NFEATURES, self._SIZE, has_bias=True, fun=activation.linear) nn.init_(l1.linear.weight, self.W) nn.init_(l1.linear.bias, self.b) l2 = nn.FeedForward(self._SIZE, self._SIZE, fun=activation.linear, has_bias=False) nn.init_(l2.linear.weight, W2) network = nn.Serial([l1, l2]) with torch.no_grad(): y = network(torch.tensor(self.x)).numpy() np.testing.assert_almost_equal(y, res, decimal=4)