inkcherry / tfv2-seqgan

0 stars 0 forks source link

ValueError: The two structures don't have the same nested structure. #1

Open shifatul-i opened 4 years ago

shifatul-i commented 4 years ago

I am using the latest version of tensorflow, and I am getting the following error. Any help is appreciated.

2020-04-20 11:53:14.982015: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2020-04-20 11:53:16.556301: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2020-04-20 11:53:16.574253: E tensorflow/stream_executor/cuda/cuda_driver.cc:351] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
2020-04-20 11:53:16.580431: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: DENOCYTE-PC
2020-04-20 11:53:16.584643: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: DENOCYTE-PC
1e-05
2020-04-20 11:53:16.601631: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
para is  1728 64 64
Generator pre-training
Model: "model_1"
_________________________________________________________________
Layer (type)                 Output Shape              Param #
=================================================================
Input (InputLayer)           [(None, None)]            0
_________________________________________________________________
Embedding (Embedding)        (None, None, 64)          110592
_________________________________________________________________
masking (Masking)            (None, None, 64)          0
_________________________________________________________________
LSTM (LSTM)                  (None, None, 64)          33024
_________________________________________________________________
TimeDenseSoftmax (TimeDistri (None, None, 1728)        112320
=================================================================
Total params: 255,936
Trainable params: 255,936
Non-trainable params: 0
_________________________________________________________________
WARNING:tensorflow:From I:\Dev\School\CSCI298\SeqGAN\train.py:67: Model.fit_generator (from tensorflow.python.keras.engine.training) is deprecated and will be removed in a future version.
Instructions for updating:
Please use Model.fit, which supports generators.
WARNING:tensorflow:sample_weight modes were coerced from
  ...
    to
  ['...']
Train for 41 steps
Epoch 1/5
41/41 [==============================] - 2s 61ms/step - loss: 2.6589
Epoch 2/5
41/41 [==============================] - 1s 26ms/step - loss: 1.7341
Epoch 3/5
41/41 [==============================] - 1s 26ms/step - loss: 1.3099
Epoch 4/5
41/41 [==============================] - 1s 25ms/step - loss: 1.2277
Epoch 5/5
41/41 [==============================] - 1s 26ms/step - loss: 1.1849
relfecting
end reflect
Start Generating sentences
mp1
 number epoch157g_samles 156generating sentences
Model: "model"
__________________________________________________________________________________________________
Layer (type)                    Output Shape         Param #     Connected to
==================================================================================================
Input (InputLayer)              [(None, None)]       0
__________________________________________________________________________________________________
Embedding (Embedding)           (None, None, 64)     110592      Input[0][0]
__________________________________________________________________________________________________
lstm (LSTM)                     (None, 64)           33024       Embedding[0][0]
__________________________________________________________________________________________________
Highway/FC_0 (Dense)            (None, 64)           4160        lstm[0][0]
__________________________________________________________________________________________________
Highway/Gate_ratio_0 (Dense)    (None, 64)           4160        lstm[0][0]
__________________________________________________________________________________________________
Highway/Gate_0 (Lambda)         (None, 64)           0           Highway/FC_0[0][0]
                                                                 lstm[0][0]
                                                                 Highway/Gate_ratio_0[0][0]
__________________________________________________________________________________________________
Dropout (Dropout)               (None, 64)           0           Highway/Gate_0[0][0]
__________________________________________________________________________________________________
FC (Dense)                      (None, 1)            65          Dropout[0][0]
==================================================================================================
Total params: 152,001
Trainable params: 152,001
Non-trainable params: 0
__________________________________________________________________________________________________
Discriminator pre-training
Traceback (most recent call last):
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\util\nest.py", line 330, in assert_same_structure
    expand_composites)
ValueError: The two structures don't have the same nested structure.

First structure: type=tuple str=(1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0)

Second structure: type=tuple str=(None,)

More specifically: The two structures don't have the same number of elements. First structure: type=tuple str=(1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0). Second structure: type=tuple str=(None,)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\keras\engine\data_adapter.py", line 1078, in broadcast_sample_weight_modes
    training_utils.list_to_tuple(sample_weight_modes))
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\util\nest.py", line 337, in assert_same_structure
    % (str(e), str1, str2))
ValueError: The two structures don't have the same nested structure.

First structure: type=tuple str=(1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0)

Second structure: type=tuple str=(None,)

More specifically: The two structures don't have the same number of elements. First structure: type=tuple str=(1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0). Second structure: type=tuple str=(None,)
Entire first structure:
(., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., .)
Entire second structure:
(.,)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\util\nest.py", line 458, in _pack_sequence_as
    0, is_seq, sequence_fn)
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\util\nest.py", line 426, in _packed_nest_with_indices
    packed.append(flat[index])
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\keras\engine\data_adapter.py", line 1088, in broadcast_sample_weight_modes
    target_structure, nest.flatten(sample_weight_modes))
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\util\nest.py", line 504, in pack_sequence_as
    return _pack_sequence_as(structure, flat_sequence, expand_composites)
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\util\nest.py", line 467, in _pack_sequence_as
    (len(flat_structure), len(flat_sequence), structure, flat_sequence))
ValueError: Could not pack sequence. Structure had 32 elements, but flat_sequence had 1 elements.  Structure: [1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0], flat_sequence: [None].

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 48, in <module>
    d_lr=config["d_pre_lr"])
  File "I:\Dev\School\CSCI298\SeqGAN\train.py", line 50, in pre_train
    self.pre_train_discriminator(d_epochs=d_epochs, d_pre_path=d_pre_path, lr=d_lr)
  File "I:\Dev\School\CSCI298\SeqGAN\train.py", line 99, in pre_train_discriminator
    epochs=d_epochs)
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\util\deprecation.py", line 324, in new_func
    return func(*args, **kwargs)
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\keras\engine\training.py", line 1306, in fit_generator
    initial_epoch=initial_epoch)
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\keras\engine\training.py", line 819, in fit
    use_multiprocessing=use_multiprocessing)
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py", line 235, in fit
    use_multiprocessing=use_multiprocessing)
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py", line 593, in _process_training_inputs
    use_multiprocessing=use_multiprocessing)
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py", line 706, in _process_inputs
    use_multiprocessing=use_multiprocessing)
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\keras\engine\data_adapter.py", line 952, in __init__
    **kwargs)
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\keras\engine\data_adapter.py", line 752, in __init__
    ) = self._canonicalize_peek(peek, kwargs.get("sample_weight_modes"))
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\keras\engine\data_adapter.py", line 808, in _canonicalize_peek
    sample_weight_modes)
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\keras\engine\data_adapter.py", line 1095, in broadcast_sample_weight_modes
    "structure:\n  {}\n    to  \n  {}".format(target_str, mode_str))
ValueError: Unable to match target structure and sample_weight_modes structure:
  ['...', '...', '...', '...', '...', '...', '...', '...', '...', '...', '...', '...', '...', '...', '...', '...', '...', '...', '...', '...', '...', '...', '...', '...', '...', '...', '...', '...', '...', '...', '...', '...']
    to
  ['...']
shifatul-i commented 4 years ago

@inkcherry any clue on how to solve this problem for TF 2.1