コード例 #1
0
 def test_return_last_splits(self):
     inputs = layers.Input(shape=(None,))
     embed = layers.Embedding(input_dim=10, output_dim=100)(inputs)
     outputs = ONLSTM(units=50, chunk_size=5, return_splits=True)(embed)
     model = models.Model(inputs=inputs, outputs=outputs)
     model.compile(optimizer='adam', loss='mse')
     model.summary(line_length=120)
     predicted = model.predict(np.random.randint(0, 10, (3, 7)))
     self.assertEqual((3, 50), predicted[0].shape)
     self.assertEqual((3, 2), predicted[1].shape)
コード例 #2
0
 def test_return_all_splits(self):
     if K.backend() == 'cntk':
         return
     inputs = layers.Input(shape=(None, ))
     embed = layers.Embedding(input_dim=10, output_dim=100)(inputs)
     outputs = ONLSTM(units=50,
                      chunk_size=5,
                      return_sequences=True,
                      return_splits=True)(embed)
     model = models.Model(inputs=inputs, outputs=outputs)
     model.compile(optimizer=self._get_optimizer(), loss='mse')
     model.summary(line_length=120)
     predicted = model.predict(np.random.randint(0, 10, (3, 7)))
     self.assertEqual((3, 7, 50), predicted[0].shape)
     self.assertEqual((3, 7, 2), predicted[1].shape)