Exemplo n.º 1
0
 def __call__(self, x, x_len):
     if self.use_mask:
         mask = self.xp.arange(x.shape[2]) < x_len[0]
         x *= mask
         x_len = (x_len + 2 * self.pad0 - self.dilate[0] * (self.ksize[0] - 1) - 1) // self.stride0 + 1
     x = F.convolution_1d(
         x=x,
         W=self.W,
         b=self.b,
         stride=self.stride,
         pad=self.pad,
         dilate=self.dilate,
         groups=self.groups)
     return x, x_len
Exemplo n.º 2
0
 def __call__(self, x, x_len):
     if self.use_mask:
         mask = F.broadcast_to(self.xp.arange(x.shape[2]), x.shape).array <\
                F.expand_dims(F.expand_dims(x_len, -1), -1).array
         x *= mask
         x_len = (x_len + 2 * self.pad0 - self.dilate[0] *
                  (self.ksize[0] - 1) - 1) // self.stride0 + 1
     x = F.convolution_1d(x=x,
                          W=self.W,
                          b=self.b,
                          stride=self.stride,
                          pad=self.pad,
                          dilate=self.dilate,
                          groups=self.groups)
     return x, x_len
Exemplo n.º 3
0
 def test_conv1d_invalid(self):
     (x, W, b) = self._get_data(2)
     with self.assertRaises(ValueError):
         F.convolution_1d(x, W, b)
Exemplo n.º 4
0
 def test_conv1d(self):
     (x, W, b) = self._get_data(1)
     testing.assert_allclose(
         F.convolution_nd(x, W, b).data, F.convolution_1d(x, W, b).data)
Exemplo n.º 5
0
 def reverse(self, x):
     return F.convolution_1d(x, self.invW)
Exemplo n.º 6
0
 def __call__(self, x):
     return F.convolution_1d(x, self.W), \
         x.shape[0] * x.shape[-1] * F.log(F.det(self.W[..., 0]))
Exemplo n.º 7
0
 def test_conv1d_invalid(self):
     (x, W, b) = self._get_data(2)
     with self.assertRaises(ValueError):
         F.convolution_1d(x, W, b)
Exemplo n.º 8
0
 def test_conv1d(self):
     (x, W, b) = self._get_data(1)
     testing.assert_allclose(
         F.convolution_nd(x, W, b).data, F.convolution_1d(x, W, b).data)