我正在尝试将此模型转换为Keras线性回归器。 当前的code:
run_config = tf.estimator.RunConfig(save_checkpoints_steps=500)
def build_model():
model = keras.Sequential([
keras.layers.Dense(64, activation=tf.nn.relu,
input_shape=(train_data.shape[1],)),
keras.layers.Dense(64, activation=tf.nn.relu),
keras.layers.Dense(1)
])
optimizer = tf.train.RMSPropOptimizer(0.001)
model.compile(loss='mse',
optimizer=optimizer,
metrics=['mae'])
return model
我将其转换为:
model = models.Sequential()
model.add(Dense(1, activation='linear', input_shape=(num_features,)))
optimizer = keras.optimizers.SGD(lr=learning_rate)
model.compile(optimizer=optimizer, loss='mse', metrics=['mae'])
return tf.keras.estimator.model_to_estimator(
keras_model=model, model_dir=model_dir, config=config)
有一个无限循环显示此内容:
WARNING:tensorflow:It seems that global step (tf.train.get_global_step) has not been increased. Current value (could be stable): 0 vs previous value: 0. You could increase the global step by passing tf.train.get_global_step() to Optimizer.apply_gradients or Optimizer.minimize.
我的学习率设置为.001 :(尝试过.01和.1)结果相同。