def forward(self, inputs): # inputs: [batch_size * num_edges, feature_dims, num_timesteps] x = self.bn1(F.relu(self.conv1(inputs))) x = F.dropout(x, self.dropout_prob) x = F.max_pooling_1d(x, 2) x = self.bn2(F.relu(self.conv2(x))) pred = self.conv_predict(x) # pred: [batch_size * num_edges, n_out, processed_timesteps] attention = F.softmax(self.conv_attention(x), axis=2) edge_prob = F.mean(pred * attention, axis=2) # edge_prob: [batch_size * num_edges, n_out] return edge_prob
def __call__(self, x): V = self.embed(x) u1 = F.relu(self.conv1(V)) u2 = F.relu(self.conv2(V)) u3 = F.relu(self.conv3(V)) u4 = F.relu(self.conv4(V)) u5 = F.relu(self.conv5(V)) m1 = F.max_pooling_1d(u1, self.filter_size[0], 1, pad=self.filter_size[0] // 2) m2 = F.max_pooling_1d(u2, self.filter_size[1], 1, pad=self.filter_size[1] // 2) m3 = F.max_pooling_1d(u3, self.filter_size[2], 1, pad=self.filter_size[2] // 2) m4 = F.max_pooling_1d(u4, self.filter_size[3], 1, pad=self.filter_size[3] // 2) m5 = F.max_pooling_1d(u5, self.filter_size[4], 1, pad=self.filter_size[4] // 2) z = F.concat([m1, m2, m3, m4, m5], axis=1) m = F.reshape(z, (z.shape[0], 300 * z.shape[1])) m = F.normalize(m, axis=1) m = self.fc2(F.dropout(m)) out = F.sigmoid(m) return out
def test_max_pooling_1d_invalid(self): (x, ksize) = self._get_data(2) with self.assertRaises(ValueError): functions.max_pooling_1d(x, ksize)
def test_max_pooling_1d(self): (x, ksize) = self._get_data(1) testing.assert_allclose( functions.max_pooling_nd(x, ksize).data, functions.max_pooling_1d(x, ksize).data)
def test_max_pooling_1d_invalid(self): (x, ksize) = self._get_data(2) with self.assertRaises(ValueError): functions.max_pooling_1d(x, ksize)
def test_max_pooling_1d(self): (x, ksize) = self._get_data(1) testing.assert_allclose( functions.max_pooling_nd(x, ksize).data, functions.max_pooling_1d(x, ksize).data)
def __call__(self, x): bottleneck = [] h = F.max_pooling_1d(self.conv1(x)), h = F.max_pooling_1d(self.conv2(x)) bottleneck = h