1. 网络构建
-
The first layer in a Sequential model must get an
input_shape
orbatch_input_shape
argument.- 序列化模型的首层必须先定义 input_shape 或 batch_input_shape 以指定输入样本的形状
model = Sequential() model.add(layers.Dense(32, activation='relu', input_shape=(64, )) model.add(layers.Dense(32, activation='relu') # 后续层次会进行自动推导,无需指定
-
model.pop():删除最后添加的层;
-
model.output_shape:查看输出层(最后添加的层)的维度;
2. 网络训练
- model.fit_generator
- 如果说训练样本树N=1000,steps_per_epoch = 10,那么相当于一个batch_size=100
- 1/10, 2/10, 3/10, 4/5, 6/10, 7/10, 8/10, 9/10, 10/10
- 共 10 个batch,每一次batch,输出最新 loss;
- 如果说训练样本树N=1000,steps_per_epoch = 10,那么相当于一个batch_size=100
3. RNN 网络
- 循环 dropout
- GRU(32, dropout=.2, recurrent_dropout=.2, input_shape=(None, seq_len))
- dropout:输入单元的dropout 比率,
- recurrent_dropout:循环单元的dropout比率;