Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertionErrors when test in tensorflow 1.13-rc0 #80

Closed
TomNong opened this issue Feb 7, 2019 · 0 comments
Closed

AssertionErrors when test in tensorflow 1.13-rc0 #80

TomNong opened this issue Feb 7, 2019 · 0 comments

Comments

@TomNong
Copy link
Collaborator

TomNong commented Feb 7, 2019

Hi,

There are 3 AssertionErrors occur when running tests, the environment is tensorflow 1.13-rc0, Python 3.6.8 (same error message as Python 2.7) and Ubuntu 16.04, the Errors are shown as below:


================================================================================================= FAILURES =================================================================================================
_________________________________________________________________________________ MergeLayerTest.test_trainable_variables __________________________________________________________________________________

self = <texar.core.layers_test.MergeLayerTest testMethod=test_trainable_variables>

    def test_trainable_variables(self):
        """Test the trainable_variables of the layer.
        """
        layers_ = []
        layers_.append(tf.layers.Conv1D(filters=200, kernel_size=3))
        layers_.append(tf.layers.Conv1D(filters=200, kernel_size=4))
        layers_.append(tf.layers.Conv1D(filters=200, kernel_size=5))
        layers_.append(tf.layers.Dense(200))
        layers_.append(tf.layers.Dense(200))
        m_layer = layers.MergeLayer(layers_)

        inputs = tf.zeros([64, 16, 1024], dtype=tf.float32)
        _ = m_layer(inputs)

        num_vars = sum([len(layer.trainable_variables) for layer in layers_])
>       self.assertEqual(num_vars, len(m_layer.trainable_variables))
E       AssertionError: 10 != 20

texar/core/layers_test.py:302: AssertionError
____________________________________________________________________________________ SequentialLayerTest.test_seq_layer ____________________________________________________________________________________

self = <texar.core.layers_test.SequentialLayerTest testMethod=test_seq_layer>

    def test_seq_layer(self):
        """Test sequential layer.
        """
        layers_ = []
        layers_.append(tf.layers.Dense(100))
        layers_.append(tf.layers.Dense(200))
        seq_layer = layers.SequentialLayer(layers_)

        output_shape = seq_layer.compute_output_shape([None, 10])
        self.assertEqual(output_shape[1].value, 200)

        inputs = tf.zeros([10, 20], dtype=tf.float32)
        outputs = seq_layer(inputs)

        num_vars = sum([len(layer.trainable_variables) for layer in layers_])
>       self.assertEqual(num_vars, len(seq_layer.trainable_variables))
E       AssertionError: 4 != 8

texar/core/layers_test.py:323: AssertionError
______________________________________________________________________________ AttentionRNNDecoderTest.test_beam_search_cell _______________________________________________________________________________

self = <texar.modules.decoders.rnn_decoders_test.AttentionRNNDecoderTest testMethod=test_beam_search_cell>

    def test_beam_search_cell(self):
        """Tests :meth:`texar.modules.AttentionRNNDecoder._get_beam_search_cell`
        """
        seq_length = np.random.randint(
            self._max_time, size=[self._batch_size]) + 1
        encoder_values_length = tf.constant(seq_length)
        hparams = {
            "attention": {
                "kwargs": {
                    "num_units": self._attention_dim,
                    "probability_fn": "sparsemax"
                }
            }
        }
        decoder = AttentionRNNDecoder(
            memory=self._encoder_output,
            memory_sequence_length=encoder_values_length,
            vocab_size=self._vocab_size,
            hparams=hparams)

        helper_train = get_helper(
            decoder.hparams.helper_train.type,
            inputs=self._inputs,
            sequence_length=[self._max_time]*self._batch_size,
            **decoder.hparams.helper_train.kwargs.todict())

        _, _, _ = decoder(helper=helper_train)

        ## 4+1 trainable variables: cell-kernel, cell-bias,
        ## fc-weight, fc-bias, and
        ## memory_layer: For LuongAttention, we only transform the memory layer;
        ## thus num_units *must* match the expected query depth.
        self.assertEqual(len(decoder.trainable_variables), 5)

        beam_width = 3
        beam_cell = decoder._get_beam_search_cell(beam_width)
        cell_input = tf.random_uniform([self._batch_size * beam_width,
                                        self._emb_dim])
        cell_state = beam_cell.zero_state(self._batch_size * beam_width,
                                          tf.float32)
        _ = beam_cell(cell_input, cell_state)
        # Test if beam_cell is sharing variables with decoder cell.
>       self.assertEqual(len(beam_cell.trainable_variables), 0)
E       AssertionError: 2 != 0

texar/modules/decoders/rnn_decoders_test.py:368: AssertionError

Hope these info be helpful in debug, thanks

@ZhitingHu ZhitingHu mentioned this issue Feb 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants