BinaryNet
BinaryNet copied to clipboard
Runtime error when running svhn.py
When running svhn.py, a runtime error occurred, indicating a dimension mismatch. Both this program and the program under BinaryConnect project have the same problem. Is there something wrong with the data I downloaded?
hanwentao@hydrogen ~/repo/BinaryNet/Train-time {env2} (master*) % python svhn.py
batch_size = 50
alpha = 0.1
epsilon = 0.0001
activation = binary_net.binary_tanh_unit
binary = True
stochastic = False
H = 1.0
W_LR_scale = Glorot
num_epochs = 200
LR_start = 0.001
LR_fin = 1e-06
LR_decay = 0.96605087899
shuffle_parts = 1
Loading SVHN dataset
Building the CNN...
W_LR_scale = 20.0499
H = 1.0
W_LR_scale = 27.7128
H = 1.0
W_LR_scale = 33.9411
H = 1.0
W_LR_scale = 39.1918
H = 1.0
W_LR_scale = 48.0
H = 1.0
W_LR_scale = 55.4256
H = 1.0
W_LR_scale = 58.4237
H = 1.0
W_LR_scale = 36.9504
H = 1.0
W_LR_scale = 26.2552
H = 1.0
Training...
Traceback (most recent call last):
File "svhn.py", line 322, in <module>
test_set.X,test_set.y)
File "/home/hanwentao/repo/BinaryConnect/binary_connect.py", line 252, in train
train_loss = train_epoch(X_train,y_train,LR)
File "/home/hanwentao/repo/BinaryConnect/binary_connect.py", line 218, in train_epoch
loss += train_fn(X[i*batch_size:(i+1)*batch_size],y[i*batch_size:(i+1)*batch_size],LR)
File "/home/hanwentao/sandbox/binarize/env2/lib/python2.7/site-packages/theano/compile/function_module.py", line
912, in __call__
storage_map=getattr(self.fn, 'storage_map', None))
File "/home/hanwentao/sandbox/binarize/env2/lib/python2.7/site-packages/theano/gof/link.py", line 314, in raise_with_op
reraise(exc_type, exc_value, exc_trace)
File "/home/hanwentao/sandbox/binarize/env2/lib/python2.7/site-packages/theano/compile/function_module.py", line
899, in __call__
self.fn() if output_subset is None else\
ValueError: Input dimension mis-match. (input[1].shape[1] = 1, input[2].shape[1] = 10)
Apply node that caused the error: Elemwise{Composite{(i0 - (i1 * ((i2 * i3) + i4)))}}(TensorConstant{(1, 1) of 1.0}
, targets, Elemwise{sub,no_inplace}.0, Elemwise{true_div,no_inplace}.0, Rebroadcast{1}.0)
Toposort index: 448
Inputs types: [TensorType(float64, (True, True)), TensorType(float64, matrix), TensorType(float64, matrix), TensorT
ype(float64, row), TensorType(float64, row)]
Inputs shapes: [(1, 1), (50, 1), (50, 10), (1, 10), (1, 10)]
Inputs strides: [(8, 8), (8, 8), (80, 8), (80, 8), (80, 8)]
Inputs values: [array([[ 1.]]), 'not shown', 'not shown', 'not shown', 'not shown']
Outputs clients: [[Elemwise{maximum,no_inplace}(TensorConstant{(1, 1) of 0.0}, Elemwise{Composite{(i0 - (i1 * ((i2
* i3) + i4)))}}.0), Elemwise{EQ}(Elemwise{maximum,no_inplace}.0, Elemwise{Composite{(i0 - (i1 * ((i2 * i3) + i4)))}
}.0)]]
HINT: Re-running with most Theano optimization disabled could give you a back-trace of when this node was created.
This can be done with by setting the Theano flag 'optimizer=fast_compile'. If that does not work, Theano optimizations can be disabled with 'optimizer=None'.
HINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node.
Closing remaining open files:/home/hanwentao/data/tmp/svhn/h5/valid_32x32.h5...done/home/hanwentao/data/tmp/svhn/h5
/test_32x32.h5...done/home/hanwentao/data/tmp/svhn/h5/splitted_train_32x32.h5...done
Hi @hanwentao , I aslo encountered the same issue. I wonder if you have figured out how to fix it? Thanks!
Your issue may be that the targets are not onehot encoded.
You may want to use this code to onehot the targets: https://github.com/MatthieuCourbariaux/BinaryNet/blob/master/Train-time/mnist.py#L109