自己用到的TensorFlow的几种输入

您所在的位置:网站首页 二维数组的输入方式有几种 自己用到的TensorFlow的几种输入

自己用到的TensorFlow的几种输入

2024-07-17 17:00| 来源: 网络整理| 查看: 265

本文列举了自己在最近用到过的几种TensorFlow输入方式,包括从原图读取,从CSV (TXT)读取,以及从bin file读取。

1, 从原图读取。

很多情况下我们的图片训练集就是原始图片本身,并没有像cifar dataset那样存成bin等格式。因此我们需要根据一个train_list列表,去挨个读取图片。这里我用到的方法是首先将train_list.txt中的image list(也就是每一行有图片的路劲和label组成)读入队列中,那么对每次dequeue的内容中可以提取当前图片的路劲和label

filename = os.path.join(data_dir, trainfilename) with open(filename) as fid: content = fid.read() content = content.split('\n') content = content[:-1] valuequeue = tf.train.string_input_producer(content,shuffle=True) value = valuequeue.dequeue() dir, labels = tf.decode_csv(records=value, record_defaults=[["string"], [""]], field_delim=" ") labels = tf.string_to_number(labels, tf.int32) 然后从路劲dir中用tf.read_file进行读取,对读到的内容用tf.image.decode_png(或者tf.image.decode_jpeg)进行解析&#


【本文地址】


今日新闻


推荐新闻


    CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3