still haven't fixed gradient propegation
"rect_dx = [-edge_lengths[0] / 2, 0, edge_lengths[0], 0, -edge_lengths[0]]\n",
"rect_dy = [-edge_lengths[1] / 2, edge_lengths[1], 0, -edge_lengths[1], 0]\n",
"\n",
- "draw_x = np.cumsum(rect_dx)\n",
- "draw_y = np.cumsum(rect_dy)\n",
+ "draw_x = tf.convert_to_tensor(np.cumsum(rect_dx), dtype=tf.float32)\n",
+ "draw_y = tf.convert_to_tensor(np.cumsum(rect_dy), dtype=tf.float32)\n",
"\n",
"coord = tf.range(0,128)"
]
" y = field_centre[1]\n",
" rand = np.random.uniform(0,1)\n",
" \n",
- " return tf.convert_to_tensor([[cos, sin, x], [-sin, cos, y], [0, 0, 1]], name=f\"transformation_{rand}\")\n",
+ " return tf.convert_to_tensor([[cos, sin, x], [-sin, cos, y], [0, 0, 1]], name=f\"transformation_{rand}\", dtype=tf.float32)\n",
"\n",
"\n",
"@tf.function\n",
"def apply_transform(xx, yy, transform):\n",
" xx_flat = tf.reshape(xx, (-1,))\n",
" yy_flat = tf.reshape(yy, (-1,))\n",
- " transformed = tf.matmul(transform, tf.stack([xx_flat, yy_flat, np.ones_like(xx_flat)], axis=0))\n",
+ " transformed = tf.matmul(transform, tf.stack([xx_flat, yy_flat, tf.ones_like(xx_flat, dtype=tf.float32)], axis=0))\n",
"\n",
" xx_transformed = transformed[0]\n",
" yy_transformed = transformed[1]\n",
"\n",
" image = 1 - (image / 127.5)\n",
" \n",
+ " encoding = tf.convert_to_tensor(encoding, dtype=tf)\n",
+ " \n",
" mask = decode(encoding)\n",
" \n",
" return image[None, ...], mask[None, ...], encoding\n",
