tensorflow实战2(梁博文 顾思宇) 学习笔记6--迁移学习,TFRecord
concept
bottleneck:
-
数据量足够的情况下,迁移学习的效果不如完全重新训练。要吸取stackGAN的教训啊,血亏
-
TFRcord 作用就是 统一不同的原始数据格式,并更加有效的管理了不同的属性
-
那么这统一的格式嘞,三种 1.bytes 2.float 3.int64
implement
- tensorflow 读取图像
image_raw_data = gfile.FastGFile(file_name,'rb').read()
- tensorflow 解码图像 img --> number
image = tf.image.decode_jpeg(image_raw_data)
- tensorflow 读取 字串图像 img_str --> number(通常读取TFRecord用)
image = tf.decode_raw(features['image_raw'],tf.uint8)
- numpy 打乱数据
state = np.ramdom.get_state()
np.random.shuffle(training_images)
np.random.set_state(state)
np.random.shuffle(training_images)
-
numpy asarray 和 array 的区别
input 为list 的时候,没区别,
import numpy as np #example 1: data1=[[1,1,1],[1,1,1],[1,1,1]] arr2=np.array(data1) arr3=np.asarray(data1) data1[1][1]=2 print 'data1:\n',data1 print 'arr2:\n',arr2 print 'arr3:\n',arr3 --------------------- data1: [[1, 1, 1], [1, 2, 1], [1, 1, 1]] arr2: [[1 1 1] [1 1 1] [1 1 1]] arr3: [[1 1 1] [1 1 1] [1 1 1]]
input 为 np.array 的时候,会copy出一个副本,占用新的内存,但asarray不会。
import numpy as np #example 2: arr1=np.ones((3,3)) arr2=np.array(arr1) arr3=np.asarray(arr1) arr1[1]=2 print 'arr1:\n',arr1 print 'arr2:\n',arr2 print 'arr3:\n',arr3 --------------------- arr1: [[ 1. 1. 1.] [ 2. 2. 2.] [ 1. 1. 1.]] arr2: [[ 1. 1. 1.] [ 1. 1. 1.] [ 1. 1. 1.]] arr3: [[ 1. 1. 1.] [ 2. 2. 2.] [ 1. 1. 1.]] --------------------- 作者:Gobsd 来源:**** 原文:https://blog.****.net/Gobsd/article/details/56485177 版权声明:本文为博主原创文章,转载请附上博文链接!