Keras.Metrics
compile & fit
以前
now
network.fit里面validation是为了提前停止;network.evaluate 验证模型最终准确率。
自定义层/网络
keras.Sequential
注意,netwok = Sequential() 这一步并没有创建w、b,在network.build() 指定输入维度,或者直接 network(x) 之后才生成w、b。
network.summary() 可查看网络结构。
自定义层
必须继承自keras.layers.Layer
自定义网络
必须继承自keras.Model
模型保存与加载
实战
import tensorflow as tf
import numpy as np
a = np.ones([10, 1])
print(type(a)) # <class 'numpy.ndarray'>
a = tf.squeeze(a)
print(type(a