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

ValueError: Tried to convert 'reduction_indices' to a tensor and failed. Error: Argument must be a dense tensor: range(0, 3) - got shape [3], but wanted []. #3

Open
abhishekshingadiya opened this issue Oct 2, 2018 · 1 comment

Comments

@abhishekshingadiya
Copy link

abhishekshingadiya commented Oct 2, 2018

File "", line 1, in
runfile('C:/Users/abhis/Downloads/Programs/gan-master/gan_train.py', wdir='C:/Users/abhis/Downloads/Programs/gan-master')

File "C:\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
execfile(filename, namespace)

File "C:\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/abhis/Downloads/Programs/gan-master/gan_train.py", line 309, in
train()

File "C:/Users/abhis/Downloads/Programs/gan-master/gan_train.py", line 243, in train
fake_image = generator(latent_input, train_logical=True)

File "C:/Users/abhis/Downloads/Programs/gan-master/gan_train.py", line 214, in generator
act1 = gen_fc_block(input, GEN_H1, GEN_W1, GEN_D1, train_logical, 'fc1')

File "C:/Users/abhis/Downloads/Programs/gan-master/gan_train.py", line 148, in gen_fc_block
bn = batch_norm(conv, train_logical=train_logical, epsilon=1e-5, decay = 0.9, scope='bn')

File "C:/Users/abhis/Downloads/Programs/gan-master/gan_train.py", line 39, in batch_norm
m, v = tf.nn.moments(x, range(ndim - 1))

File "C:\Anaconda3\lib\site-packages\tensorflow\python\ops\nn_impl.py", line 690, in moments
mean = math_ops.reduce_mean(y, axes, keepdims=True, name="mean")

File "C:\Anaconda3\lib\site-packages\tensorflow\python\util\deprecation.py", line 432, in new_func
return func(*args, **kwargs)

File "C:\Anaconda3\lib\site-packages\tensorflow\python\ops\math_ops.py", line 1453, in reduce_mean
name=name))

File "C:\Anaconda3\lib\site-packages\tensorflow\python\ops\gen_math_ops.py", line 4793, in mean
name=name)

File "C:\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 528, in _apply_op_helper
(input_name, err))

ValueError: Tried to convert 'reduction_indices' to a tensor and failed. Error: Argument must be a dense tensor: range(0, 3) - got shape [3], but wanted [].

i used pydb so i detect that error coming from this line 39 m, v = tf.nn.moments(x, range(ndim - 1))

abhishekshingadiya added a commit to abhishekshingadiya/gan that referenced this issue Oct 2, 2018
@Nolleschorsch
Copy link

wrap the range in a list.
change range(ndim - 1) to list(range(ndim - 1))

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

2 participants