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

TypeError: unsupported operand type(s) for /: 'Dimension' and 'int' #83

Closed
Yaredoh opened this issue May 11, 2017 · 7 comments
Closed

Comments

@Yaredoh
Copy link

Yaredoh commented May 11, 2017

Am using tensorflow 1.0 and python 3.6. can you check it ?

Traceback (most recent call last):
File "train.py", line 253, in
main()
File "train.py", line 144, in main
net = DeepLabResNetModel({'data': image_batch}, is_training=args.is_training, num_classes=args.num_classes)
File "/home/batuser/Documents/color/kaffe/tensorflow/network.py", line 48, in init
self.setup(is_training, num_classes)
File "/home/batuser/Documents/color/deeplab_resnet/model.py", line 114, in setup
.atrous_conv(3, 3, 256, 2, padding='SAME', biased=False, relu=False, name='res4a_branch2b')
File "/home/batuser/Documents/color/kaffe/tensorflow/network.py", line 22, in layer_decorated
layer_output = op(self, layer_input, *args, **kwargs)
File "/home/batuser/Documents/color/kaffe/tensorflow/network.py", line 170, in atrous_conv
kernel = self.make_var('weights', shape=[k_h, k_w, c_i / group, c_o])
TypeError: unsupported operand type(s) for /: 'Dimension' and 'int'

@cbessega
Copy link

cbessega commented May 11, 2017

I had the same problem. You will need to do a bunch of small tweaks to make it work in Python 3.6.
In case you are not especially interested in Python 3.6, the repo runs perfectly fine in 2.7

In that particular case what happens is that get_shape() in a couple of places of kaffe/tensorflow/network.py returns a dimension.

To get the shape as a list of ints, do tensor.get_shape().as_list()

@Yaredoh
Copy link
Author

Yaredoh commented May 11, 2017

Thanks, @cbessega I will check it on 2.7.

@DrSleep DrSleep closed this as completed Jul 6, 2017
@NitishMutha
Copy link

Hi, @cbessega, @DrSleep can you let me know what all fixes would be required to make it compatible with 3.6?
Since i am on windows machine, tensorflow on windows just supports python >= 3.5, so i would have to make those fixes to make it work on my machine.

@yemanbh
Copy link

yemanbh commented Aug 15, 2017

type casting the Dimension to int will solve the problem: if you have a=10, dim = X.shape[10], then instead of adim use aint(dim)

@fastlater
Copy link

For newbies (like me) and as mentioned in #80
from line:
kernel = self.make_var('weights', shape=[k_h, k_w, c_i / group, c_o])
change it to:
kernel = self.make_var('weights', shape=[k_h, k_w, int(c_i) / group, c_o])

@dwleeKAIST
Copy link

sz = input.shape
sz[0] : Dimension type.
You need to use typecasting by ' int(sz[0]) '.

@kourouklides
Copy link

FYI I had exactly the same error when running the Transformer tutorial and I managed to resolve it by adding .numpy() at the end, i.e. temp_learning_rate_schedule(tf.range(40000, dtype=np.float32)).numpy()

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

8 participants