예제 #1
0
 def test_repeat(self):
     """Test invoking Repeat in eager mode."""
     with context.eager_mode():
         input = np.random.rand(5, 4).astype(np.float32)
         result = layers.Repeat(3)(input)
         assert result.shape == (5, 3, 4)
         assert np.array_equal(result[:, 0, :], result[:, 1, :])
예제 #2
0
파일: seqtoseq.py 프로젝트: zhoutf/deepchem
 def _create_decoder(self, n_layers, dropout):
   """Create the decoder layers."""
   prev_layer = layers.Repeat(
       self._max_output_length, in_layers=self.embedding)
   for i in range(n_layers):
     if dropout > 0.0:
       prev_layer = layers.Dropout(dropout, in_layers=prev_layer)
     prev_layer = layers.GRU(
         self._embedding_dimension, self.batch_size, in_layers=prev_layer)
   return layers.Dense(
       len(self._output_tokens),
       in_layers=prev_layer,
       activation_fn=tf.nn.softmax)