heuritech / convnets-keras

MIT License
594 stars 185 forks source link

Alexnet issue with Keras 2 #46

Open srinivaschalamala opened 7 years ago

srinivaschalamala commented 7 years ago

The following line gives error in Keras 2.0.4

conv_2 = merge([Convolution2D(128, (5, 5), activation="relu", name='conv2' + str(i + 1))( splittensor(ratio_split=2, id_split=i)(conv_2) ) for i in range(2)], mode='concat', concat_axis=1, name="conv_2")

Error:

ValueError: Input dimension mis-match. (input[0].shape[1] = 96, input[4].shape[1] = 95) Apply node that caused the error: Elemwise{Composite{(i0 / ((i1 + (i2 i3) + (i2 i4) + (i2 i5) + (i2 i6) + (i2 * i7)) * i8))}}[(0, 0)](Pool{ignore_border=True, mode='max', ndim=2}.0, TensorConstant{(1, 1, 1, 1) of 2.0}, TensorConstant{(1, 1, 1, .. of 0.0001}, InplaceDimShuffle{0,3,1,2}.0, Subtensor{::, int64:int64:}.0, Subtensor{::, int64:int64:}.0, Subtensor{::, int64:int64:}.0, Subtensor{::, int64:int64:}.0, TensorConstant{(1, 1, 1, 1) of 0.75}) Toposort index: 23 Inputs types: [TensorType(float32, 4D), TensorType(float32, (True, True, True, True)), TensorType(float32, (True, True, True, True)), TensorType(float32, 4D), TensorType(float32, 4D), TensorType(float32, 4D), TensorType(float32, 4D), TensorType(float32, 4D), TensorType(float32, (True, True, True, True))] Inputs shapes: [(1, 96, 27, 27), (1, 1, 1, 1), (1, 1, 1, 1), (1, 96, 27, 29), (1, 95, 27, 29), (1, 94, 27, 29), (1, 93, 27, 29), (1, 92, 27, 29), (1, 1, 1, 1)] Inputs strides: [(279936, 2916, 108, 4), (4, 4, 4, 4), (4, 4, 4, 4), (384, 4, 11136, 384), (384, 4, 11136, 384), (384, 4, 11136, 384), (384, 4, 11136, 384), (384, 4, 11136, 384), (4, 4, 4, 4)] Inputs values: ['not shown', array([[[[ 2.]]]], dtype=float32), array([[[[ 9.99999975e-05]]]], dtype=float32), 'not shown', 'not shown', 'not shown', 'not shown', 'not shown', array([[[[ 0.75]]]], dtype=float32)] Inputs type_num: [11, 11, 11, 11, 11, 11, 11, 11, 11] Outputs clients: [[IncSubtensor{InplaceSet;::, ::, int64:int64:, int64:int64:}(Alloc.0, Elemwise{Composite{(i0 / ((i1 + (i2 i3) + (i2 i4) + (i2 i5) + (i2 i6) + (i2 i7)) ** i8))}}[(0, 0)].0, Constant{2}, Constant{29}, Constant{2}, Constant{29})]]

Debugprint of the apply node: Elemwise{Composite{(i0 / ((i1 + (i2 i3) + (i2 i4) + (i2 i5) + (i2 i6) + (i2 * i7)) * i8))}}[(0, 0)] [id A] <TensorType(float32, 4D)> ''
|Pool{ignore_border=True, mode='max', ndim=2} [id B] <TensorType(float32, 4D)> ''
| |Elemwise{Composite{(i0
((i1 + i2) + Abs((i1 + i2))))}}[(0, 1)] [id C] <TensorType(float32, 4D)> ''
| | |TensorConstant{(1, 1, 1, 1) of 0.5} [id D] <TensorType(float32, (True, True, True, True))> | | |CorrMM{valid, (4, 4), (1, 1)} [id E] <TensorType(float32, 4D)> ''
| | | |/input_1 [id F] <TensorType(float32, 4D)> | | | |Subtensor{::, ::, ::int64, ::int64} [id G] <TensorType(float32, 4D)> ''
| | | |InplaceDimShuffle{3,2,0,1} [id H] <TensorType(float32, 4D)> ''
| | | | |conv_1/kernel [id I] <TensorType(float32, 4D)> | | | |Constant{-1} [id J] | | | |Constant{-1} [id J] | | |InplaceDimShuffle{x,0,x,x} [id K] <TensorType(float32, (True, False, True, True))> ''
| | |conv_1/bias [id L] <TensorType(float32, vector)> | |TensorConstant{(2,) of 3} [id M] <TensorType(int64, vector)> | |TensorConstant{(2,) of 2} [id N] <TensorType(int64, vector)> | |TensorConstant{(2,) of 0} [id O] <TensorType(int64, vector)> |TensorConstant{(1, 1, 1, 1) of 2.0} [id P] <TensorType(float32, (True, True, True, True))> |TensorConstant{(1, 1, 1, .. of 0.0001} [id Q] <TensorType(float32, (True, True, True, True))> |InplaceDimShuffle{0,3,1,2} [id R] <TensorType(float32, 4D)> ''
| |IncSubtensor{InplaceSet;::, ::, int64:int64:, int64:int64:} [id S] <TensorType(float32, 4D)> ''
| |Alloc [id T] <TensorType(float32, 4D)> ''
| | |TensorConstant{0.0} [id U] <TensorType(float32, scalar)> | | |Shape_i{0} [id V] <TensorType(int64, scalar)> ''
| | | |/input_1 [id F] <TensorType(float32, 4D)> | | |TensorConstant{27} [id W] <TensorType(int64, scalar)> | | |TensorConstant{29} [id X] <TensorType(int64, scalar)> | | |TensorConstant{96} [id Y] <TensorType(int64, scalar)> | |Elemwise{sqr,no_inplace} [id Z] <TensorType(float32, 4D)> ''
| | |InplaceDimShuffle{0,2,3,1} [id BA] <TensorType(float32, 4D)> ''
| | |Pool{ignore_border=True, mode='max', ndim=2} [id B] <TensorType(float32, 4D)> ''
| |Constant{0} [id BB] | |Constant{27} [id BC] | |Constant{0} [id BB] | |Constant{96} [id BD] |Subtensor{::, int64:int64:} [id BE] <TensorType(float32, 4D)> ''
| |InplaceDimShuffle{0,3,1,2} [id R] <TensorType(float32, 4D)> ''
| |Constant{1} [id BF] | |Constant{97} [id BG] |Subtensor{::, int64:int64:} [id BH] <TensorType(float32, 4D)> ''
| |InplaceDimShuffle{0,3,1,2} [id R] <TensorType(float32, 4D)> ''
| |Constant{2} [id BI] | |Constant{98} [id BJ] |Subtensor{::, int64:int64:} [id BK] <TensorType(float32, 4D)> ''
| |InplaceDimShuffle{0,3,1,2} [id R] <TensorType(float32, 4D)> ''
| |Constant{3} [id BL] | |Constant{99} [id BM] |Subtensor{::, int64:int64:} [id BN] <TensorType(float32, 4D)> ''
| |InplaceDimShuffle{0,3,1,2} [id R] <TensorType(float32, 4D)> ''
| |Constant{4} [id BO] | |Constant{100} [id BP] |TensorConstant{(1, 1, 1, 1) of 0.75} [id BQ] <TensorType(float32, (True, True, True, True))>