0

我正在尝试使用时间线分析 GPflow 并使用 chrome 跟踪对其进行可视化。但迹线似乎没有显示优化过程(仅模型构建和预测)。我定义了一个自定义配置:

custom_config = gpflow.settings.get_settings()
custom_config.profiling.output_file_name = 'gpflow_timeline'
custom_config.profiling.dump_timeline = True

并尝试在优化后做一个简单的预测:

with gpflow.settings.temp_settings(custom_config), gpflow.session_manager.get_session().as_default():
   k = gpflow.kernels.RBF()
   m = gpflow.models.GPR(X_train, y_train, kern=k)
   run_adam(m, lr=0.1, iterations=100, callback=__PrintAction(m, 'GPR with Adam'))
   mean, var = m.predict_y(X_test)

其中 Adam 优化器定义为:

class __PrintAction(Action):
   def __init__(self, model, text):
       self.model = model
       self.text = text

   def run(self, ctx):
       likelihood = ctx.session.run(self.model.likelihood_tensor)
       print('{}: iteration {} likelihood {:.4f}'.format(self.text, ctx.iteration, likelihood))

def run_adam(model, lr, iterations, callback=None):
   adam = gpflow.train.AdamOptimizer(lr).make_optimize_action(model)
   actions = [adam] if callback is None else [adam, callback]
   loop = Loop(actions, stop=iterations)()
   model.anchor(model.enquire_session()) 

是否有可能在时间线上也显示优化跟踪?

4

2 回答 2

0

我已经设定:

custom_config.profiling.each_time = True

每次运行后获取跟踪文件。然后我使用以下方法合并了痕迹jq

jq -s '{traceEvents: map(.traceEvents[])}' gpflow_timeline_* >> gpflow_timeline_all.json
于 2019-05-24T09:14:31.573 回答
0

扩展到@tadejk 答案:

您可以gpflowrc在 GPflow/gpflow 项目文件夹中进行修改,或者在运行代码并在那里调整分析参数的同一文件夹中创建它。

[logging]
# possible levels: CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET
level = WARNING

[verbosity]
tf_compile_verb = False

[dtypes]
float_type = float64
int_type = int32

[numerics]
jitter_level = 1e-6
# quadrature can be set to: allow, warn, error
ekern_quadrature = warn

[profiling]
dump_timeline = False
dump_tensorboard = False
output_file_name = timeline
output_directory = ./
each_time = False

[session]
intra_op_parallelism_threads = 0
inter_op_parallelism_threads = 0

不是 100% 肯定,但是将所有内容合并到一个 json 文件中可能是个坏主意。session.run 生成的单个文件,因此将所有内容合并到一个文件中可能会搞砸。

于 2019-05-24T10:47:15.463 回答