Tacotron-2: unexpected keyword argument 'previous_alignments'

Created on 10 Apr 2018  路  12Comments  路  Source: Rayhane-mamah/Tacotron-2

Traceback (most recent call last):
  File "/home/zeng/work/pycharm/Tacotron-2/train.py", line 32, in <module>
    main()
  File "/home/zeng/work/pycharm/Tacotron-2/train.py", line 26, in main
    tacotron_train(args)
  File "/home/zeng/work/pycharm/Tacotron-2/tacotron/train.py", line 183, in tacotron_train
    train(log_dir, args)
  File "/home/zeng/work/pycharm/Tacotron-2/tacotron/train.py", line 73, in train
    model.initialize(feeder.inputs, feeder.input_lengths, feeder.mel_targets, feeder.token_targets)
  File "/home/zeng/work/pycharm/Tacotron-2/tacotron/models/tacotron.py", line 106, in initialize
    maximum_iterations=max_iters)
  File "/home/zeng/tf_gpu_py3/lib/python3.5/site-packages/tensorflow/contrib/seq2seq/python/ops/decoder.py", line 286, in dynamic_decode
    swap_memory=swap_memory)
  File "/home/zeng/tf_gpu_py3/lib/python3.5/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2816, in while_loop
    result = loop_context.BuildLoop(cond, body, loop_vars, shape_invariants)
  File "/home/zeng/tf_gpu_py3/lib/python3.5/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2640, in BuildLoop
    pred, body, original_loop_vars, loop_vars, shape_invariants)
  File "/home/zeng/tf_gpu_py3/lib/python3.5/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2590, in _BuildLoop
    body_result = body(*packed_vars_for_body)
  File "/home/zeng/tf_gpu_py3/lib/python3.5/site-packages/tensorflow/contrib/seq2seq/python/ops/decoder.py", line 234, in body
    decoder_finished) = decoder.step(time, inputs, state)
  File "/home/zeng/work/pycharm/Tacotron-2/tacotron/models/custom_decoder.py", line 123, in step
    (cell_outputs, stop_token), cell_state = self._cell(inputs, state)
  File "/home/zeng/work/pycharm/Tacotron-2/tacotron/models/Architecture_wrappers.py", line 194, in __call__
    attention_layer=None)
  File "/home/zeng/tf_gpu_py3/lib/python3.5/site-packages/tensorflow/contrib/seq2seq/python/ops/attention_wrapper.py", line 973, in _compute_attention
    cell_output, previous_alignments=previous_alignments)
TypeError: __call__() got an unexpected keyword argument 'previous_alignments'

Hi,Rayhane-mamah, greate job! I try to train the model,but get this error.it seems that previous_alignments is not a parameter in LocationSensitiveAttention ? anything wrong?

Most helpful comment

Hello again,

Tensorflow 1.6 is no longer a must, I added the possibility to use the project with tensorflow 1.4 in this commit (0330bd0161e4530acbb7bc2db00a1db95b2dc107).

For that purpose I added the attention_old.py file. It might have been possible to simply change the function call in the same existing attention.py file, but I wanted to avoid any conflicts so I made a copy of the attention file and adapted the call function to work with Tensorflow 1.4 API.

If you encounter any further issues, please report them.

All 12 comments

Hi @zhf459, you need TensorFlow 1.6. The keyword-name has changed from 1.5 to 1.6.

same error as I meet before, @Rayhane-mamah I think add tensorflow==1.6 to requirement.txt can reduce this kind of issue

Hello,

You need tensorflow 1.6 indeed.

@butterl I didn't want to add it there to not affect pre installed tensorflow gpu. I will however try to add working version for tf 1.4.

@Rayhane-mamah ,I hope it works for tf 1.4 too.

It doesn't for now, I will try adding this dependency in the next 24 hours if you don't want to upgrade.

Sorry for the inconvenience.

Hello again,

Tensorflow 1.6 is no longer a must, I added the possibility to use the project with tensorflow 1.4 in this commit (0330bd0161e4530acbb7bc2db00a1db95b2dc107).

For that purpose I added the attention_old.py file. It might have been possible to simply change the function call in the same existing attention.py file, but I wanted to avoid any conflicts so I made a copy of the attention file and adapted the call function to work with Tensorflow 1.4 API.

If you encounter any further issues, please report them.

@Rayhane-mamah that's great, thank you!

@Rayhane-mamah can you tell me more about this issue please. thank you

Hello @Rayhane-mamah
when i try to train the model, it raise an error with Tensorflow 1.4 .
is there a way to fix it ? thank you ~

Traceback (most recent call last):
  File "train.py", line 81, in <module>
    main()
  File "train.py", line 75, in main
    train(args, log_dir, hparams)
  File "train.py", line 27, in train
    checkpoint = tacotron_train(args, log_dir, hparams)
  File "/root/synthetic/tacotron-2/tacotron/train.py", line 329, in tacotron_train
    train(log_dir, args, hparams)
  File "/root/synthetic/tacotron-2/tacotron/train.py", line 139, in train
    model, stats = model_train_mode(args, feeder, hparams, global_step)
  File "/root/synthetic/tacotron-2/tacotron/train.py", line 75, in model_train_mode
    is_training=True)
  File "/root/synthetic/tacotron-2/tacotron/models/tacotron.py", line 69, in initialize
    zoneout=hp.tacotron_zoneout_rate, scope='encoder_LSTM'))
  File "/root/synthetic/tacotron-2/tacotron/models/modules.py", line 139, in __init__
    name='encoder_fw_LSTM')
  File "/root/synthetic/tacotron-2/tacotron/models/modules.py", line 39, in __init__
    self._cell = tf.nn.rnn_cell.LSTMCell(num_units, state_is_tuple=state_is_tuple, name=name)
TypeError: __init__() got an unexpected keyword argument 'name'

Hello @ArashHosseini sorry for the late reply, I see you are using anold_attention.py file we used to have, could you try using our new attention.py file? it is compatible with tf 1.4 because I made it independent from tf _compute_attention predefined function. The problem seems to be related to some shape mismatch which can be caused by other components of the network you are trying to use our attention on..

Hello @ArloZ thanks for reaching out!
It appears that fortf 1.4 API and earlier LSTMCell didn't have a name argument in their constructor.. I believe simply takingname parameter off will just do. or you could also save the name in a self.scope variable and use it when calling the cell:
https://github.com/Rayhane-mamah/Tacotron-2/blob/d375c67fbfda2989294ecb4ec9892762055d8277/tacotron/models/modules.py#L55

@Rayhane-mamah, Thank you for your answer. I tried your "new" attention.py file, again I hit the "TypeError: __call __ () got an unexpected keyword argument 'previous_alignments'
" error.
But before that I would like to try your repo. i used the preprocess step

Max input length (text chars): 187
Max mel frames length: 873
Max audio timesteps length: 224256

and removed the "name" param, now on training(default hp) this happens:

python3.5 -Xfaulthandler train.py --model='Both'
Using TensorFlow backend.

#############################################################

Tacotron Train

###########################################################

Checkpoint path: logs-Both/taco_pretrained/tacotron_model.ckpt
Loading training data from: training_data/train.txt
Using model: Both
Hyperparameters:
  allow_clipping_in_normalization: True
  attention_dim: 128
  attention_filters: 32
  attention_kernel: (31,)
  cin_channels: 80
...
  wavenet_random_seed: 5339
  wavenet_swap_with_cpu: False
  wavenet_test_batches: None
  wavenet_test_size: 0.0441
Loaded Metadata for 13100 examples (24.06 hours)
Initialized Tacotron model. Dimensions (? = dynamic shape): 
  Train mode:               True
  Eval mode:                False
  GTA mode:                 False
  Synthesis mode:           False
  embedding:                (?, ?, 512)
  enc conv out:             (?, ?, 512)
  encoder out:              (?, ?, 512)
  decoder out:              (?, ?, 80)
  residual out:             (?, ?, 512)
  projected residual out:   (?, ?, 80)
  mel out:                  (?, ?, 80)
  <stop_token> out:         (?, ?)
Initialized Tacotron model. Dimensions (? = dynamic shape): 
  Train mode:               False
  Eval mode:                True
  GTA mode:                 False
  Synthesis mode:           False
  embedding:                (?, ?, 512)
  enc conv out:             (?, ?, 512)
  encoder out:              (?, ?, 512)
  decoder out:              (?, ?, 80)
  residual out:             (?, ?, 512)
  projected residual out:   (?, ?, 80)
  mel out:                  (?, ?, 80)
  <stop_token> out:         (?, ?)
Tacotron training set to a maximum of 320000 steps
src/tcmalloc.cc:277] Attempt to free invalid pointer 0x6f732e 
Fatal Python error: Aborted

Current thread 0x00007f41a6ad3780 (most recent call first):
  File "/usr/local/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 622 in __init__
  File "/usr/local/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1482 in __init__
  File "/home/flyn/git/Tacotron-2/tacotron/train.py", line 143 in train
  File "/home/flyn/git/Tacotron-2/tacotron/train.py", line 305 in tacotron_train
  File "train.py", line 28 in train
  File "train.py", line 79 in main
  File "train.py", line 85 in <module>
Aborted (core dumped)

@Rayhane-mamah i downloaded also the pre-trained file and on synthesize.py the same issue

python3.5 synthesize.py --model='Tacotron-2'
Using TensorFlow backend.
Running End-to-End TTS Evaluation. Model: Tacotron-2
Synthesizing mel-spectrograms from text..
loaded model at logs-Both/taco_pretrained/model.ckpt-182000
Hyperparameters:
  allow_clipping_in_normalization: True
  attention_dim: 128
  attention_filters: 32
  attention_kernel: (31,)
  cin_channels: 80
...
  wavenet_learning_rate: 0.0001
  wavenet_random_seed: 5339
  wavenet_swap_with_cpu: False
  wavenet_test_batches: None
  wavenet_test_size: 0.0441
Constructing model: Tacotron
Fatal Python error: Segmentation fault

Current thread 0x00007f2698e85780 (most recent call first):
  File "/usr/local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 2561 in _extract_stack
  File "/usr/local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1470 in __init__
  File "/usr/local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 2956 in create_op
  File "/usr/local/lib/python3.5/site-packages/tensorflow/python/framework/constant_op.py", line 214 in constant
  File "/usr/local/lib/python3.5/site-packages/tensorflow/python/framework/constant_op.py", line 229 in _constant_tensor_conversion_function
  File "/usr/local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 926 in internal_convert_to_tensor
  File "/usr/local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 991 in internal_convert_n_to_tensor
  File "/usr/local/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py", line 455 in _apply_op_helper
  File "/usr/local/lib/python3.5/site-packages/tensorflow/python/ops/gen_logging_ops.py", line 47 in _assert
  File "/usr/local/lib/python3.5/site-packages/tensorflow/python/ops/control_flow_ops.py", line 127 in Assert
  File "/usr/local/lib/python3.5/site-packages/tensorflow/python/util/tf_should_use.py", line 107 in wrapped
  File "/usr/local/lib/python3.5/site-packages/tensorflow/python/ops/check_ops.py", line 320 in assert_equal
  File "/home/flyn/git/Tacotron-2/tacotron/models/Architecture_wrappers.py", line 116 in _batch_size_checks
  File "/home/flyn/git/Tacotron-2/tacotron/models/Architecture_wrappers.py", line 157 in zero_state
  File "/home/flyn/git/Tacotron-2/tacotron/models/tacotron.py", line 110 in initialize
  File "/home/flyn/git/Tacotron-2/tacotron/synthesizer.py", line 27 in load
  File "/home/flyn/git/Tacotron-2/tacotron/synthesize.py", line 57 in run_eval
  File "/home/flyn/git/Tacotron-2/tacotron/synthesize.py", line 134 in tacotron_synthesize
  File "synthesize.py", line 32 in synthesize
  File "synthesize.py", line 85 in main
  File "synthesize.py", line 91 in <module>
Segmentation fault (core dumped)

(he missing "name" parameter may cause this error - Segmentation fault and not OOM, can not find any gpu consumption in nvidia-smi. i suspect without the associated scope, the memory access is denied. so i tried with adding
self.scope=name
on init and changing line 55 to
output, new_state = self._cell(inputs, state, self.scope)
and still getting the same output.
thank you

Our latest version are independent from tensorflow's attention wrappers so this issue should be fixed.

Was this page helpful?
0 / 5 - 0 ratings