TensorFlowException TF_INVALID_ARGUMENT "No OpKernel was registered to support Op 'Reshape' with these attrs.
I can't get reshape to work. In the tensorflow-mnist example (https://github.com/tensorflow/haskell/blob/master/tensorflow-mnist/app/Main.hs) if I replace
let hiddenZ = (images `TF.matMul` hiddenWeights) `TF.add` hiddenBiases
with
let hiddenZ = ((TF.reshape images (TF.vector [batchSize, numPixels])) `TF.matMul` hiddenWeights) `TF.add` hiddenBiases
(which should have no effect because the shape is the same), I get the following error.
Main: TensorFlowException TF_INVALID_ARGUMENT "No OpKernel was registered to support Op 'Reshape' with these attrs. Registered devices: [CPU], Registered kernels:\n device='GPU'; T in [DT_COMPLEX128]; Tshape in [DT_INT32]\n device='GPU'; T in [DT_COMPLEX64]; Tshape in [DT_INT32]\n device='GPU'; T in [DT_INT8]; Tshape in [DT_INT32]\n device='GPU'; T in [DT_UINT8]; Tshape in [DT_INT32]\n device='GPU'; T in [DT_INT16]; Tshape in [DT_INT32]\n device='GPU'; T in [DT_UINT16]; Tshape in [DT_INT32]\n device='GPU'; T in [DT_INT64]; Tshape in [DT_INT32]\n device='GPU'; T in [DT_DOUBLE]; Tshape in [DT_INT32]\n device='GPU'; T in [DT_FLOAT]; Tshape in [DT_INT32]\n device='GPU'; T in [DT_HALF]; Tshape in [DT_INT32]\n device='CPU'; Tshape in [DT_INT32]\n\n\t [[Node: Reshape_27 = Reshape[T=DT_FLOAT, Tshape=DT_INT64](Placeholder_0:0, Const_26:0)]]"
Process exited with ExitFailure 1: /home/optml/holdenl/tensorflow-haskell/.stack-work/install/x86_64-linux-dkd1ce2ff9c9560b648268df668d177711/lts-6.2/7.10.3/bin/Main
Looks like a fallout from using Int64 for dimensions. Apparently Reshape is not implemented for Int64 shapes.
We want: [[Node: Reshape_27 = Reshape[T=DT_FLOAT, Tshape=DT_INT64](Placeholder_0:0, Const_26:0)]]" Yet the only possible match is: device='CPU'; Tshape in [DT_INT32]
It looks like the kernel is more restrictive than the op (which allows int32 and int64): https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/kernels/reshape_op.cc#L54 https://github.com/tensorflow/tensorflow/blob/1a0742f6a7a06ff54481385b5c51094b0fef8cf3/tensorflow/core/ops/array_ops.cc#L1555
See discussion here which previously moved this error from runtime to graph construction.