My codes:
def f(x):
try:
import tensorflow as tf
# x is (None, 10, 2)
idx = K.cast(x*15.5+15.5, "int32")
z = tf.sparse_to_dense(idx, 32, 1.0, 0.0, name='sparse_tensor')
print('z.shape={0}'.format(z.shape))
except Exception as e:
print(e)
return x[:, :, 0:2]
drop_out = Lambda(lambda x: f(x),
output_shape=drop_output_shape, name='projection')(reshape_out)
x is tensor of (None, 10, 2)
, where there are 10 indexes/coordinates. Trying to generate a (None, 32, 32)
tensor z
. I got the following error:
Shape must be rank 1 but is rank 0 for 'projection_14/sparse_tensor' (op: 'SparseToDense') with input shapes: [?,10,2], [], [], [].
How to fix it? Thanks