我已经一遍又一遍地查看我的代码,但是我一生都无法弄清楚发生语法错误的位置。 React说我在代码here的第15行中缺少分号,非常感谢另一双眼睛替我看这个!
答案 0 :(得分:1)
您的import tensorflow as tf
import numpy as np
array1 = np.array([0,0,0,0,1,1,1,0,0,0,]) # this is the multi-labeled data
def array_example(label):
#bits = tf.io.read_file(filename) # returns a tensor of type string
feature = {
#'label': _float_feature(label),
'label': tf.train.Feature(int64_list=tf.train.Int64List(value=label)),
#'image_raw': _bytes_feature(bits),
}
return tf.train.Example(features=tf.train.Features(feature=feature))
record_file = 'images.tfrecords'# the name of the file to write these into
with tf.io.TFRecordWriter(record_file) as writer:
tf_example = array_example(array1)
writer.write(tf_example.SerializeToString())
#**Read Back**
raw_image_dataset = tf.data.TFRecordDataset('images.tfrecords')
# Create a dictionary describing the features.
image_feature_description = {
'label': tf.io.FixedLenFeature([], tf.int64),
#'image_raw': tf.io.FixedLenFeature([], tf.string),
}# same the one what we use to write the images in..
def _parse_image_function(example_proto):
# Parse the input tf.Example proto using the dictionary above.
return tf.io.parse_single_example(example_proto, image_feature_description)
parsed_image_dataset = raw_image_dataset.map(_parse_image_function)
parsed_image_dataset
for image_features in parsed_image_dataset:
#print(image_features)
image_raw = image_features['label']#.numpy()
#print(image_raw)
应该用小写字母书写。
答案 1 :(得分:0)
答案 2 :(得分:0)
使用Let
关键字时,您错了。它必须是let
。