Machine Learning:Training Models

摘要

Previous

前文回顾:

上面的文章中提到了机器学习的预测结果受模型质量的影响很大,如果想要取得好的效果需要通过训练增强优化。

Training Data

1
curl http://download.tensorflow.org/example_images/flower_photos.tgz \| tar xz -C tf_files

Training the Network

1
git clone https://github.com/googlecodelabs/tensorflow-for-poets-2
1
2
3
4
python scripts/retrain.py
--image_dir=tf_files/flower_photos
--output_graph=tf_files/retrained_graph.pb
--output_labels=tf_files/retrained_labels.txt

Test:Using the Retrained Model

1
python scripts/label_image.py --image data/daisy.jpg

Model

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
node {
name: "DecodeJpeg/contents"
op: "Const"
attr {
key: "dtype"
value {
type: DT_STRING
}
}
attr {
key: "value"
value {
tensor {
dtype: DT_STRING
tensor_shape {
}
string_val: "\377\330......."
}
}
}
}

node {
name: "softmax/biases"
op: "Const"
attr {
key: "dtype"
value {
type: DT_FLOAT
}
}
attr {
key: "value"
value {
tensor {
dtype: DT_FLOAT
tensor_shape {
dim {
size: 1008
}
}
tensor_content: "\312\277\006"
}
}
}
}
node {
name: "softmax/logits/MatMul"
op: "MatMul"
input: "pool_3/_reshape"
input: "softmax/weights"
attr {
key: "T"
value {
type: DT_FLOAT
}
}
attr {
key: "transpose_a"
value {
b: false
}
}
attr {
key: "transpose_b"
value {
b: false
}
}
}
node {
name: "softmax/logits"
op: "BiasAdd"
input: "softmax/logits/MatMul"
input: "softmax/biases"
attr {
key: "T"
value {
type: DT_FLOAT
}
}
}
node {
name: "softmax"
op: "Softmax"
input: "softmax/logits"
attr {
key: "T"
value {
type: DT_FLOAT
}
}
}

Optional Parameters

Questions

1
2
3
4
22:17:28.523085: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
22:17:28 NodeDef mentions attr 'dilations' not in Op<name=Conv2D; signature=input:T, filter:T -> output:T; attr=T:type,allowed=[DT_HALF, DT_FLOAT]; attr=strides:list(int); attr=use_cudnn_on_gpu:bool,default=true; attr=padding:string,allowed=["SAME", "VALID"]; attr=data_format:string,default="NHWC",allowed=["NHWC", "NCHW"]>; NodeDef: conv/Conv2D = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], padding="VALID", strides=[1, 2, 2, 1], use_cudnn_on_gpu=true](Mul, conv/conv2d_params). (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.).

22:22:02.629987: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.2 AVX AVX2 FMA

About Data Sets

扩展阅读:《The Machine Learning Master》

参考文献

欢迎扫码关注微信公众号获取最新动态,读者交流 QQ 群:338272982 。

推荐文章