Guest User

Untitled

a guest
Dec 9th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. reshape_out = Reshape((21, 3), input_shape=(21*3,), name='reshape_to_21_3')(output3d)
  2.  
  3. def proj_output_shape(shp):
  4. return (None, 32, 32, 1)
  5.  
  6. def f(x):
  7. import tensorflow as tf
  8. batch_size = K.shape(x)[0]
  9.  
  10. print('x.shape={0}'.format(x.shape))
  11. idx = K.cast(x[:, :, 0:2]*15.5+15.5, "int64")
  12. print('idx.shape={0}'.format(idx.shape))
  13.  
  14. # z = mysparse_to_dense(idx, (K.shape(x)[0], 32, 32), 1.0, 0.0, name='sparse_tensor')
  15. updates = tf.ones([batch_size, 21])
  16.  
  17. print('updates.shape={0}'.format(updates.shape))
  18.  
  19. z = tf.scatter_nd(indices=idx,
  20. updates=updates,
  21. shape = (K.shape(x)[0], 32, 32),
  22. name='cool')
  23.  
  24. print('z={0}'.format(z))
  25. z = tf.add(z, z)
  26. #z = tf.sparse_add(tf.zeros(z.dense_shape), z)
  27. z = K.reshape(z, (K.shape(x)[0], 32, 32, 1))
  28. fil = make_kernel(1.0)
  29. fil = K.reshape(fil, (5, 5, 1, 1))
  30.  
  31. print('z.shape={0}'.format(z.shape), z)
  32. print('fil.shape={0}'.format(fil.shape), fil)
  33.  
  34. r = K.conv2d(z,kernel=fil, padding='same', data_format="channels_last")
  35. print('r.shape={0}'.format(r.shape), r)
  36.  
  37. return r
  38.  
  39. proj_out = Lambda(lambda x: f(x),
  40. output_shape=proj_output_shape, name='projection')(reshape_out)
  41.  
  42. x.shape=(?, 21, 3)
  43. idx.shape=(?, 21, 2)
  44. updates.shape=(?, 21)
  45.  
  46. ValueError: The inner 1 dimensions of output.shape=[?,?,?] must match the inner 0 dimensions of updates.shape=[?,21]: Shapes must be equal rank, but are 1 and 0 for 'projection_20/cool' (op: 'ScatterNd') with input shapes: [?,21,2], [?,21], [3].
Add Comment
Please, Sign In to add comment