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

NameError: name 'reduce' is not defined #49

Closed
mloenow opened this issue Oct 28, 2017 · 2 comments
Closed

NameError: name 'reduce' is not defined #49

mloenow opened this issue Oct 28, 2017 · 2 comments
Assignees

Comments

@mloenow
Copy link

mloenow commented Oct 28, 2017

Great project — thanks for making it!

While trying to use the PlaidML backend in my code, I encountered a problem when trying to flatten my input.

Traceback (most recent call last):
  File "ddpq_dreams.py", line 73, in <module>
    actor.add(Flatten(input_shape=(1, ) + env.observation_space.shape))
  File "/usr/local/anaconda3/lib/python3.6/site-packages/keras/models.py", line 442, in add
    layer(x)
  File "/usr/local/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py", line 602, in __call__
    output = self.call(inputs, **kwargs)
  File "/usr/local/anaconda3/lib/python3.6/site-packages/keras/layers/core.py", line 484, in call
    return K.batch_flatten(inputs)
  File "/usr/local/anaconda3/lib/python3.6/site-packages/plaidml/keras/backend.py", line 1008, in batch_flatten
    return x.batch_flatten()
  File "/usr/local/anaconda3/lib/python3.6/site-packages/plaidml/keras/backend.py", line 509, in batch_flatten
    new_shape = (self.shape[0], reduce(operator.mul, self.shape[1:]))
NameError: name 'reduce' is not defined

The same error actually happens when executing a the plaidvision and plaidbench examples with a few of the models e.g. python plaidvision.py resnet50 and python plaidbench.py resnet50 --print-stacktraces:

Using PlaidML backend.
INFO:plaidml:b'Opening device "amd_radeon_r9_m370x_compute_engine.0'
Traceback (most recent call last):
  File "plaidvision.py", line 310, in <module>
    main()
  File "plaidvision.py", line 260, in main
    model = Model(args.model, args.weights)
  File "plaidvision.py", line 206, in __init__
    self.model = ModelClass(weights=weights)
  File "/usr/local/anaconda3/lib/python3.6/site-packages/keras/applications/resnet50.py", line 235, in ResNet50
    x = Flatten()(x)
  File "/usr/local/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py", line 602, in __call__
    output = self.call(inputs, **kwargs)
  File "/usr/local/anaconda3/lib/python3.6/site-packages/keras/layers/core.py", line 484, in call
    return K.batch_flatten(inputs)
  File "/usr/local/anaconda3/lib/python3.6/site-packages/plaidml/keras/backend.py", line 1008, in batch_flatten
    return x.batch_flatten()
  File "/usr/local/anaconda3/lib/python3.6/site-packages/plaidml/keras/backend.py", line 509, in batch_flatten
    new_shape = (self.shape[0], reduce(operator.mul, self.shape[1:]))
NameError: name 'reduce' is not defined

System:

MacBook Pro (Retina, 15-inch, Mid 2015)
AMD Radeon R9 M370X 2 GB
macOS 10.13
Python 3.6.2
Keras (2.0.8)
plaidml (0.1.1)
plaidml-keras (0.1.1)

Please let me know if you need more information.

@jbruestle jbruestle reopened this Oct 28, 2017
@jbruestle
Copy link
Contributor

I believe this issue is related to python 3.6. 'reduce' moved from a free function to into the functools module. Thanks for reporting it, we will try to correct this as soon as possible. Currently the 3.6 version has limited test coverage. We are expanding our internal and open source test intergration to help find such issues earlier.

@brianretford brianretford self-assigned this Oct 28, 2017
@brianretford
Copy link

brianretford commented Oct 28, 2017

This is fixed at head. We've just released a patch pip that resolves this issue. pip install -U plaidml-keras Thanks for reporting the issue!

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

3 participants