pytorch2keras icon indicating copy to clipboard operation
pytorch2keras copied to clipboard

reshape after view is wrong

Open ShuangLiu1992 opened this issue 5 years ago • 2 comments

Describe the bug Linear followed by a view leads to incorrect result, tensorflowjs complains shape mismatch [NULL, output_size]. changing reshape = keras.layers.Reshape([-1], name=tf_name) to match the input shape seems to fix the problem

To Reproduce Snippet of your code

x = x.view(self.batch_size, -1)
self.output = nn.Linear(x.shape[1], output_size)

ShuangLiu1992 avatar May 14 '19 13:05 ShuangLiu1992

I find the same problem,so how can you handle it?

ifve avatar Aug 28 '19 06:08 ifve

https://github.com/nerox8664/pytorch2keras/pull/77

had a pull request, fixed my problem but didn't get merged

ShuangLiu1992 avatar Aug 28 '19 08:08 ShuangLiu1992