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

when i run the test code, i have got an error! #4

Open
LinTANGSS opened this issue Aug 14, 2018 · 4 comments
Open

when i run the test code, i have got an error! #4

LinTANGSS opened this issue Aug 14, 2018 · 4 comments

Comments

@LinTANGSS
Copy link

Traceback (most recent call last):
File "/home/tanglin/data/Code/DCNets/dcnet_cifar100/linear_cos/train_resnet.py", line 161, in
train(args.base_lr, args.batch_size)
File "/home/tanglin/data/Code/DCNets/dcnet_cifar100/linear_cos/train_resnet.py", line 49, in train
vgg.build(images, n_class, is_training)
File "/home/tanglin/data/Code/DCNets/dcnet_cifar100/linear_cos/architecture.py", line 168, in build
name='root', bn=True, pad='SAME', norm=True, reg=False, orth=True)
File "/home/tanglin/data/Code/DCNets/dcnet_cifar100/linear_cos/architecture.py", line 118, in _conv_layer
self._add_orthogonal_constraint(filt, n_filt)
File "/home/tanglin/data/Code/DCNets/dcnet_cifar100/linear_cos/architecture.py", line 99, in _add_orthogonal_constraint
wnorm = self._get_filter_norm(filt)
File "/home/tanglin/data/Code/DCNets/dcnet_cifar100/linear_cos/architecture.py", line 87, in _get_filter_norm
return tf.sqrt(tf.reduce_sum(filt*filt, [0, 1, 2], keep_dims=True)+eps)
File "/home/tanglin/anaconda3/envs/tf1.9/lib/python2.7/site-packages/tensorflow/python/ops/math_ops.py", line 1206, in reduce_sum
name=name)
File "/home/tanglin/anaconda3/envs/tf1.9/lib/python2.7/site-packages/tensorflow/python/ops/gen_math_ops.py", line 2804, in _sum
keep_dims=keep_dims, name=name)
File "/home/tanglin/anaconda3/envs/tf1.9/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 763, in apply_op
op_def=op_def)
File "/home/tanglin/anaconda3/envs/tf1.9/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2329, in create_op
set_shapes_for_outputs(ret)
File "/home/tanglin/anaconda3/envs/tf1.9/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1717, in set_shapes_for_outputs
shapes = shape_func(op)
File "/home/tanglin/anaconda3/envs/tf1.9/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1667, in call_with_requiring
return call_cpp_shape_fn(op, require_shape_fn=True)
File "/home/tanglin/anaconda3/envs/tf1.9/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 610, in call_cpp_shape_fn
debug_python_shape_fn, require_shape_fn)
File "/home/tanglin/anaconda3/envs/tf1.9/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 676, in _call_cpp_shape_fn_impl
raise ValueError(err.message)
ValueError: Invalid reduction dimension 2 for input with 2 dimensions. for 'root/Sum' (op: 'Sum') with input shapes: [27,96], [3].

@leeguandong
Copy link

I also encountered the same mistake. How did you solve it?

@futureisatyourhand
Copy link

I solved this problem, /linear_cos/architecture.py is on line 87,
Converting"return tf.sqrt(tf.reduce_sum(filtfilt, [0, 1,2], keep_dims=True)+eps)"
  To "return tf.sqrt(tf.reduce_sum(filt
filt, [0, 1], keep_dims=True)+eps)"

@bqhu
Copy link

bqhu commented Oct 31, 2019

p=filt.get_shape().as_list()
dim_s=list(range(len(p)-1))
return tf.sqrt(tf.reduce_sum(filt*filt,dim_s, keep_dims=True)+eps)
this will solve the problem

@qujz
Copy link

qujz commented Jun 4, 2020

I solved this problem, /linear_cos/architecture.py is on line 87,
Converting"return tf.sqrt(tf.reduce_sum(filt_filt, [0, 1,2], keep_dims=True)+eps)"   To "return tf.sqrt(tf.reduce_sum(filt_filt, [0, 1], keep_dims=True)+eps)"

Hello, I modified the code according to your answer, but it still shows an error. Can you discuss it on email or WeChat with me? my mailbox is [email protected]. Thank you very much.

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

5 participants