我有一些数组,假设a = np.asarray([[10, 50], [30, 60]])
我知道像素的颜色是colors = np.asarray([['G', 'R'], ['B', 'G']])
我想以 .raw(或 .dng)格式保存图像。我该怎么做呢?
我想将张量保存为 TFRecord 格式。我试过这个:
import tensorflow as tf
x = tf.constant([[2.0, 3.0, 3.0],
[1.0, 5.0, 9.0]], dtype='float32')
x2 = tf.io.serialize_tensor(x)
# I understand that I can parse it using this:
# x3 = tf.io.parse_tensor(x2, 'float32')
record_file = 'temp.tfrecord'
with tf.io.TFRecordWriter(record_file) as writer:
writer.write(x2)
Run Code Online (Sandbox Code Playgroud)
它给了我错误:
TypeError: write(): incompatible function arguments. The following argument types are supported:
1. (self: tensorflow.python._pywrap_record_io.RecordWriter, record: str) -> None
Run Code Online (Sandbox Code Playgroud)
我知道这可能是一个基本问题,但我阅读了 TensorFlow 网站上的指南并在 StackOverflow 中搜索,但没有找到答案