question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: l2_normalize() got an unexpected keyword argument 'axis'

See original GitHub issue

Hi, i use this code to create your own model with own dataset , but occure this error.

Warning (from warnings module): File “C:\Python36\lib\site-packages\h5py_init_.py”, line 36 from ._conv import register_converters as _register_converters FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type. Using TensorFlow backend. Traceback (most recent call last): File “C:\Python36\ssd_keras-master\train_ssd300.py”, line 59, in <module> swap_channels=swap_channels) File “C:\Python36\ssd_keras-master\keras_ssd300.py”, line 287, in ssd_300 conv4_3_norm = L2Normalization(gamma_init=20, name=‘conv4_3_norm’)(conv4_3) File “C:\Python36\lib\keras\engine\topology.py”, line 619, in call output = self.call(inputs, **kwargs) File “C:\Python36\ssd_keras-master\keras_layer_L2Normalization.py”, line 63, in call output = K.l2_normalize(x, self.axis) File “C:\Python36\lib\keras\backend\tensorflow_backend.py”, line 3151, in l2_normalize return tf.nn.l2_normalize(x, axis=axis) TypeError: l2_normalize() got an unexpected keyword argument ‘axis’

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

15reactions
pierluigiferraricommented, Apr 18, 2018

What version of TensorFlow are you using?

The error message is pretty clear: tf.nn.l2_normalize() doesn’t have a parameter named axis in your version of TensorFlow, implying that you are using a version of TensorFlow that is too old.

EDIT: For anybody having this issue in the future, the error is caused by an incompatibility between your TensorFlow and Keras versions. TensorFlow changed the name of the concerned argument from dim to axis (I believe in version 1.5), and Keras adopted this change in a recent release (I believe 2.1.5). This means you must run TF and Keras versions that are consistent in this regard, i.e. versions that call this argument by the same name. If you run Keras 2.1.5 or later, then you must also run TF 1.5/1.6 or later. Conversely, if you run TF 1.4 or earlier, then you must also run Keras 2.1.4 or earlier.

2reactions
juiceboxjoecommented, Apr 10, 2018

Update: I just solved the issue. It was my Keras 2.1.5 version that caused the problem. tensorflow-gpu v.1.4.1 was breaking but only because Keras 2.1.5 was making incorrect use of the following call:

/path/to/ssd_keras/ssd_venv/lib/python3.5/site-packages/keras/backend/tensorflow_backend.py in l2_normalize(x, axis)
   3149         A tensor.
   3150     """
-> 3151     return tf.nn.l2_normalize(x, axis=axis)

I solved by downgrading to Keras v. 2.1.4

Read more comments on GitHub >

github_iconTop Results From Across the Web

swaplevel() got an unexpected keyword argument 'axis ...
i have checked the pandas doc and the fucntion does take axis as argument, what am i doing wrong please ! thank you...
Read more >
<lambda>() got an unexpected keyword argument 'axis' - Reddit
It seems like in df.apply(lambda x: 1, axis=1) axis=1 is parsed as an argument to the pandas apply() method, but in ...
Read more >
Keras报错l2_normalize() got an unexpected keyword ...
【代码】CosMix环境配置点云域自适应语义分割方法环境配置。 TypeError: softmax() got an unexpected keyword argument 'axis' 解决办法.
Read more >
Writing custom array containers — NumPy v1.23 Manual
To get a feel for writing custom array containers, we'll begin with a simple example that has ... TypeError: sum() got an unexpected...
Read more >
from_dict() got an unexpected keyword argument 'index' - You ...
But it says it from_dict doesn't take a column argument. TypeError: from_dict () got unexpected keyword argument 'columns'. Have 2 answer (s) found....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found