我正在使用tensorflow回调在tensorboard上进行可视化显示。
tensorboard = tf.keras.callbacks.TensorBoard(
log_dir='logs',
histogram_freq=1,
write_graph=True,
write_images=True,
update_freq='epoch',
profile_batch=2,
embeddings_freq=1,
)
我正在使用简单模型,并使用数据管道作为模型的输入。这里的要素层包含每个要素的feature_columns:
model = tf.keras.Sequential([
feature_layer,
tf.keras.layers.Dense(units = 12, activation='relu', use_bias = True, kernel_initializer= 'glorot_uniform', bias_initializer = 'zeros'),
tf.keras.layers.Dense(units = 6, activation='relu', use_bias = True, kernel_initializer= 'glorot_uniform', bias_initializer = 'zeros'),
tf.keras.layers.Dense(units = 2, activation='softmax')
])
我正在使用adam作为优化程序,将稀疏的分类交叉熵作为损失,将准确性作为度量。 这是我的张量板图:
red line = train
blue line = validation
我的问题是为什么它显示的培训步骤少于验证步骤。
答案 0 :(得分:1)
如果您查看tf.keras.callbacks.TensorBoard的tensorflow文档,则在profile_batch
的参数部分下,其格式如下-
profile_batch
:分析批次以采样计算特征。 profile_batch必须是非负整数或正整数对的逗号分隔字符串。一对正整数表示要分析的批次范围。默认情况下,它将配置第二批。将profile_batch = 0设置为禁用分析。必须在TensorFlow急切模式下运行。
您已设置profile_batch=2
,因此它仅显示第二批的结果。
示例-
# profile a single batch, e.g. the 5th batch.
tensorboard_callback =
tf.keras.callbacks.TensorBoard(log_dir='./logs', profile_batch=5)
model.fit(x_train, y_train, epochs=2, callbacks=[tensorboard_callback])
# run the tensorboard command to view the visualizations in profile plugin.
# profile a range of batches, e.g. from 10 to 20.
tensorboard_callback =
tf.keras.callbacks.TensorBoard(log_dir='./logs', profile_batch='10,20')
model.fit(x_train, y_train, epochs=2, callbacks=[tensorboard_callback])
# run the tensorboard command to view the visualizations in profile plugin.
设置profile_batch=0
以禁用性能分析。必须在TensorFlow急切模式下运行。