wentaozhu / deep-mil-for-whole-mammogram-classification

Zhu, Wentao, Qi Lou, Yeeleng Scott Vang, and Xiaohui Xie. "Deep Multi-instance Networks with Sparse Label Assignment for Whole Mammogram Classification." MICCAI 2017.
MIT License
113 stars 36 forks source link

Error on line "alexmodel = convnet('alexnet', weights_path='alexnet_weights.h5', heatmap=False, l1=l1factor, l2=l2factor)" #6

Closed classxiaoli closed 6 years ago

classxiaoli commented 7 years ago

The error happens on that line and it's hard to debug.

Traceback (most recent call last): File "run_cnn_k_new.py", line 98, in alexmodel = convnet('alexnet', weights_path='alexnet_weights.h5', heatmap=False, l1=l1factor, l2=l2factor) File "/usr/local/lib/python2.7/dist-packages/convnetskeras/convnets.py", line 85, in convnet sparsemil=sparsemil, sparsemill1=sparsemill1, sparsemill2=sparsemill2, saveact=saveact) File "/usr/local/lib/python2.7/dist-packages/convnetskeras/convnets.py", line 375, in AlexNet dense_1 = Dense(4096, activation='relu',name='dense_1',W_regularizer=l1l2(l1=l1factor, l2=l2factor))(dense_1) File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 550, in call self.build(input_shapes[0]) File "/usr/local/lib/python2.7/dist-packages/keras/layers/core.py", line 754, in build constraint=self.W_constraint) File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 415, in add_weight weight = initializer(shape, name=name) File "/usr/local/lib/python2.7/dist-packages/keras/initializations.py", line 60, in glorot_uniform return uniform(shape, s, name=name) File "/usr/local/lib/python2.7/dist-packages/keras/initializations.py", line 33, in uniform return K.random_uniform_variable(shape, -scale, scale, name=name) File "/usr/local/lib/python2.7/dist-packages/keras/backend/theano_backend.py", line 182, in random_uniform_variable return variable(np.random.uniform(low=low, high=high, size=shape), File "mtrand.pyx", line 1302, in mtrand.RandomState.uniform (numpy/random/mtrand/mtrand.c:19349) File "mtrand.pyx", line 242, in mtrand.cont2_array_sc (numpy/random/mtrand/mtrand.c:7415) ValueError: negative dimensions are not allowed

And we print out shape in "return variable(np.random.uniform(low=low, high=high, size=shape)", and find shape becomes (-3840,4096), which means there is a negative dimension in the dense layer. Everything before looks OK. Do you know what might cause the issue?

wentaozhu commented 7 years ago

Please try to print the input data size and keras configuration, and each layer's size for debug purpose.

classxiaoli commented 7 years ago

We have figure the issue out. Thanks!