Writing Prediction to TF record format
I am facing this issue while writing the predictions to TF record format .
**This is my code**
`
writer = tf.io.TFRecordWriter('/content/drive/MyDrive/ssapkota913_VNM_1989_1990_1679042822/VNM_1989_1990.TFRecord')
patch = [[]]
cur_patch = 1
for prediction in predictions:
patch[0].append(tf.argmax(prediction, 1))
if (len(patch[0]) == patch_width * patch_height):
print('Done with patch ' + str(cur_patch) + ' of ' + str(patches) + '...')
example = tf.train.Example(
features=tf.train.Features(
feature={
'prediction': tf.train.Feature(
int64_list=tf.train.Int64List(
value = patch[0]))
}
)
)
writer.write(example.SerializeToString())
patch = [[]]
cur_patch += 1
writer.close()`
**My error is as following :**
TypeError Traceback (most recent call last)
[<ipython-input-49-68e9caca011c>](https://localhost:8080/#) in <module>
21 feature={
22 'prediction': tf.train.Feature(
---> 23 int64_list=tf.train.Int64List(
24 value = patch[0]))
25 # 'bareProb': tf.train.Feature(
[/usr/local/lib/python3.9/dist-packages/tensorflow/python/framework/ops.py](https://localhost:8080/#) in __index__(self)
1061
1062 def __index__(self):
-> 1063 return self._numpy().__index__()
1064
1065 def __bool__(self):
TypeError: only integer scalar arrays can be converted to a scalar index
0 条评论