I’m trying to get a reshape layer to work, I’m first creating a shape like this
let batch_size = 10
let shape:Tensor<Int32> = [batch_size, 7, 7, 256]
But then I get this error
error: <Cell 57>:2:28: error: cannot convert value of type 'Int' to expected element type '_TensorElementLiteral<Int32>'
let shape:Tensor<Int32> = [batch_size, 7, 7, 256]
^~~~~~~~~~
_TensorElementLiteral<Int32>( )
The thing is I need later to pass this object to Reshape, e.g.
let batch_size = 10
let target_shape = TensorShape([batch_size, 7, 7, 256])
let r1 = Reshape<Float>(shape: target_shape)
But now it’s complaining
error: <Cell 79>:3:32: error: cannot convert value of type 'TensorShape' to expected argument type 'Tensor<Int32>'
let r1 = Reshape<Float>(shape: target_shape)
^~~~~~~~~~~~
Use the init without the shape argument name. The init you are using needs to be passed a tensor not a TensorShape. So do it the following way. I tried it in Colab and it works.
let batch_size = 10
let target_shape = TensorShape([batch_size, 7, 7, 256])
let r1 = Reshape<Float>(target_shape)