我使用tf.estimator API创建了一个浅NN。我想在TensorFlow开发者峰会上与https://www.youtube.com/watch?time_continue=948&v=eBbEDRsCmv4中解释的超参数搜索类似。
我找不到任何有关如何执行此操作的更新文档。我有以下代码(我会尽量简化):
# Define nn architecture
def neural_net(features):
input_layer = tf.cast(features['x'], tf.float32)
hidden_layer = nn_layer(input_layer, 10, 'hidden_layer', act=tf.nn.relu)
out_layer = nn_layer(hidden_layer, 2, 'out_layer', act=tf.nn.relu)
return out_layer
# Define model function
def model_fn(features, labels, mode):
# Build the neural network
logits = neural_net(features<9
with tf.name_scope('loss'):
# Define loss and optimizer
loss = tf.losses.sparse_softmax_cross_entropy(logits=logits, labels=labels)
# Configure the Training
if mode == tf.estimator.ModeKeys.TRAIN:
optimizer = tf.train.GradientDescentOptimizer(learning_rate=0.001)
train_op = optimizer.minimize(
loss=loss,
global_step=tf.train.get_global_step())
return tf.estimator.EstimatorSpec(mode=mode, loss=loss, train_op=train_op)
nn_classifier = tf.estimator.Estimator(model_fn=model_fn)
train_input_fn = tf.estimator.inputs.numpy_input_fn(
x={"x": train_data},
y=train_labels,
batch_size=100,
num_epochs=None,
shuffle=True)
nn_classifier.train(
input_fn=train_input_fn,
steps=20000
)
执行此代码我可以获取损失的摘要并在Tensorboard中观察它。但想象一下,我想获得不同的曲线。假设我想看看损失是如何随着样本的数量而演变的,所以我会训练两个不同样本大小的模型。或两个具有不同架构的模型......无论如何。
如何在Tensorboard中获得这两条曲线?