numpy 배열에서 tfrecord 형식으로 데이터 집합을 만들려고합니다. 2 차원 및 3 차원 좌표를 저장하려고합니다.numpy 배열을 tfrecord로 저장하는 방법은 무엇입니까?
def _floats_feature(value):
return tf.train.Feature(float_list=tf.train.FloatList(value=value))
train_filename = 'train.tfrecords' # address to save the TFRecords file
writer = tf.python_io.TFRecordWriter(train_filename)
for c in range(0,1000):
#get 2d and 3d coordinates and save in c2d and c3d
feature = {'train/coord2d': _floats_feature(c2d),
'train/coord3d': _floats_feature(c3d)}
sample = tf.train.Example(features=tf.train.Features(feature=feature))
writer.write(sample.SerializeToString())
writer.close()
:
2 차원 좌표는 3 차원 좌표를 입력 float64
의 모양 (3,10)의 NumPy와 배열입니다 float64 타입의 모양 (2,10)의 NumPy와 배열이 내 코드되어 있습니다 나는이 문제를 해결하는 방법을 잘 모릅니다
feature = {'train/coord2d': _floats_feature(c2d),
File "genData.py", line 19, in _floats_feature
return tf.train.Feature(float_list=tf.train.FloatList(value=value))
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\google\protobuf\internal\python_message.py", line 510, in init
copy.extend(field_value)
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\google\protobuf\internal\containers.py", line 275, in extend
new_values = [self._type_checker.CheckValue(elem) for elem in elem_seq_iter]
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\google\protobuf\internal\containers.py", line 275, in <listcomp>
new_values = [self._type_checker.CheckValue(elem) for elem in elem_seq_iter]
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\google\protobuf\internal\type_checkers.py", line 109, in CheckValue
raise TypeError(message)
TypeError: array([-163.685, 240.818, -114.05 , -518.554, 107.968, 427.184,
157.418, -161.798, 87.102, 406.318]) has type <class 'numpy.ndarray'>, but expected one of: ((<class 'numbers.Real'>,),)
:이 프로그램을 실행할 때
내가이 오류가 발생합니다. 내가 int64 또는 바이트로 기능을 저장해야합니까? 나는 완전히 새로운 tensorflow에 이르기 때문에 이것에 대해 갈 방법이 없다. 어떤 도움이 될거야! 감사