Skip to content

UserWarning and TypeError when using Keras v2.x+ #34

Description

@jungwon1413

Environment Info

Operating Hardware: local Workstation with Nvidia 1080ti
Operating System: Ubuntu 16.04 LTS
Installed CUDA / CuDNN: (doesn't matter, but just in case)

  • CUDA: 8.0
  • CuDNN: 6.0

pip packages

  • Keras 2.1.1
  • Tensorflow 1.4.0,

Problem:

  • When I install ba-dls-deepspeech with instruction following along, certain errors arises if I execute train.py.

Main Reason:

  • This is when I use up-to-date Keras which has partially changed for layer functions used in model.py.

How I solved:

Log:

Using TensorFlow backend.
WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.
2017-12-19 14:10:19,570 INFO    (data_generator) Reading description file: ba_ds_ETRI_train_corpus.jsonl for partition: train
2017-12-19 14:10:19,888 INFO    (data_generator) Reading description file: ba_ds_ETRI_test_corpus.jsonl for partition: validation
2017-12-19 14:10:21,062 INFO    (model) Building gru model
/media/clab/1TB_HDD/baidu_deepspeech/model.py:109: UserWarning: Update your `Conv1D` call to the Keras 2 API: `Conv1D(1000, 11, activation="relu", padding="valid", kernel_initializer="glorot_uniform", strides=2, name="conv1d")`
  activation='relu')(acoustic_input)
Traceback (most recent call last):
  File "train.py", line 155, in <module>
    args.sortagrad)
  File "train.py", line 123, in main
    model = compile_gru_model(recur_layers=3, nodes=1000, batch_norm=True)
  File "/media/clab/1TB_HDD/baidu_deepspeech/model.py", line 111, in compile_gru_model
    output = BatchNormalization(name='bn_conv_1d', mode=2)(conv_1d)
  File "/home/clab/.local/lib/python3.5/site-packages/keras/legacy/interfaces.py", line 30, in wrapper
    args, kwargs, converted = preprocessor(args, kwargs)
  File "/home/clab/.local/lib/python3.5/site-packages/keras/legacy/interfaces.py", line 446, in batchnorm_args_preprocessor
    raise TypeError('The `mode` argument of `BatchNormalization` '
TypeError: The `mode` argument of `BatchNormalization` no longer exists. `mode=1` and `mode=2` are no longer supported.

Log2:

Using TensorFlow backend.
WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.
2017-12-19 15:39:07,863 INFO    (data_generator) Reading description file: ./corpus/train_100_corpus.jsonl for partition: train
2017-12-19 15:39:07,952 INFO    (data_generator) Reading description file: ./corpus/validate_clean_corpus.jsonl for partition: validation
2017-12-19 15:39:08,551 INFO    (model) Building gru model
/media/clab/1TB_HDD/baidu_deepspeech/model.py:109: UserWarning: Update your `Conv1D` call to the Keras 2 API: `Conv1D(1000, 11, padding="valid", kernel_initializer="glorot_uniform", activation="relu", name="conv1d", strides=2)`
  activation='relu')(acoustic_input)
/media/clab/1TB_HDD/baidu_deepspeech/model.py:118: UserWarning: Update your `GRU` call to the Keras 2 API: `GRU(1000, kernel_initializer="glorot_uniform", return_sequences=True, activation="relu", name="rnn_1")`
  return_sequences=True)(output)
/media/clab/1TB_HDD/baidu_deepspeech/model.py:118: UserWarning: Update your `GRU` call to the Keras 2 API: `GRU(1000, kernel_initializer="glorot_uniform", return_sequences=True, activation="relu", name="rnn_2")`
  return_sequences=True)(output)
/media/clab/1TB_HDD/baidu_deepspeech/model.py:118: UserWarning: Update your `GRU` call to the Keras 2 API: `GRU(1000, kernel_initializer="glorot_uniform", return_sequences=True, activation="relu", name="rnn_3")`
  return_sequences=True)(output)
/media/clab/1TB_HDD/baidu_deepspeech/model.py:125: UserWarning: Update your `Dense` call to the Keras 2 API: `Dense(29, activation="linear", kernel_initializer="glorot_uniform", name="dense")`
  output_dim, name='dense', activation='linear', init=initialization,
/media/clab/1TB_HDD/baidu_deepspeech/model.py:127: UserWarning: Update your `Model` call to the Keras 2 API: `Model(inputs=Tensor("ac..., outputs=Tensor("ti...)`
  model = Model(input=acoustic_input, output=network_output)
2017-12-19 15:39:12,264 INFO    (model) Building train_fn
Traceback (most recent call last):
  File "train.py", line 155, in <module>
    args.sortagrad)
  File "train.py", line 126, in main
    train_fn = compile_train_fn(model)
  File "/media/clab/1TB_HDD/baidu_deepspeech/model.py", line 35, in compile_train_fn
    network_output = network_output.dimshuffle((1, 0, 2))
AttributeError: 'Tensor' object has no attribute 'dimshuffle'

AttributeError: 'Tensor' object has no attribute 'dimshuffle' is not related with Keras, but rather with tensorflow's Tensor module.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions