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 [].
File "
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
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))
wrap the range in a list.
change range(ndim - 1) to list(range(ndim - 1))