pytorch2keras icon indicating copy to clipboard operation
pytorch2keras copied to clipboard

ValueError: Layer weight shape (1, 512) not compatible with provided weight shape (2048, 512)

Open poormag opened this issue 5 years ago • 2 comments

Thanx for your pytorch2keras. I dont know, maybe its not about convertation problem but maybe you have some advices to me. I did according to the example, like:

input_np = np.random.uniform(0, 1, (8, 3, 256, 128)) input_var = Variable(torch.FloatTensor(input_np))

but then im trying to compile it with shape like this:

k_model = pytorch_to_keras(net,input_var,[(3, 256, 128,)], verbose=True)

an error pops up:

DEBUG:onnx2keras:gemm:Input units 2048, output units 512.

Traceback (most recent call last): 'provided weight shape ' + str(w.shape))

ValueError: Layer weight shape (1, 512) not compatible with provided weight shape (2048, 512)

With shape like this:

k_model = pytorch_to_keras(net,dummy_input,[(3, None, None,)], verbose=True)

another error pops up:

DEBUG:onnx2keras:gemm:Input` units 2048, output units 512.

............................ return ufunc.reduce(obj, axis, dtype, out, **passkwargs)

TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

Is there some problem with me? Thanx for advices

Environment (please complete the following information):

  • OS: Ubuntu 18.0
  • Python 3.7

poormag avatar Oct 09 '19 09:10 poormag

Thanx for your pytorch2keras. I dont know, maybe its not about convertation problem but maybe you have some advices to me. I did according to the example, like: input_np = np.random.uniform(0, 1, (8, 3, 256, 128)) input_var = Variable(torch.FloatTensor(input_np)) but then im trying to compile it with shape like this: k_model = pytorch_to_keras(net,input_var,[(3, 256, 128,)], verbose=True) an error pops up:

DEBUG:onnx2keras:gemm:Input units 2048, output units 512.

Traceback (most recent call last): 'provided weight shape ' + str(w.shape)) ValueError: Layer weight shape (1, 512) not compatible with provided weight shape (2048, 512) With shape like this: k_model = pytorch_to_keras(net,dummy_input,[(3, None, None,)], verbose=True) another error pops up:

DEBUG:onnx2keras:gemm:Input` units 2048, output units 512.

............................ return ufunc.reduce(obj, axis, dtype, out, **passkwargs) TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType' Is there some problem with me? Thanx for advices Environment (please complete the following information):

OS: Ubuntu 18.0 Python 3.7

Has your problem been solved?

tbbjymm21 avatar Mar 03 '20 03:03 tbbjymm21

@poormag @tbbjymm21 were you able to resolve this issue?

shairoz-deci avatar Apr 26 '21 14:04 shairoz-deci