我还没有在里利卜文档中看到任何允许我在keras中打印像print(model.summary())这样的模型快速摘要的东西。我试过用tf-slim和
variables = tf.compat.v1.model_variables()
slim.model_analyzer.analyze_vars(variables, print_info=True)为了大致了解tensorflow模型,但是在初始化模型之后(在ESTrainer类_init的末尾插入)没有发现任何变量。具体来说,我一直试图得到一个进化策略(ES)策略的摘要,以验证对模型配置的更改是否正在按预期更新,但我无法获得摘要打印工作。
有没有一种现有的方法来解决这个问题?斯利姆会在这里工作吗?
发布于 2022-01-04 08:20:56
培训代理可以返回允许您访问模型的策略:
agent = ppo.PPOTrainer(config, env=select_env)
policy = agent.get_policy()
policy.model.base_model.summary() # Prints the model summary样本输出:
Layer (type) Output Shape Param # Connected to
==================================================================================================
observations (InputLayer) [(None, 7)] 0 []
fc_1 (Dense) (None, 256) 2048 ['observations[0][0]']
fc_value_1 (Dense) (None, 256) 2048 ['observations[0][0]']
fc_2 (Dense) (None, 256) 65792 ['fc_1[0][0]']
fc_value_2 (Dense) (None, 256) 65792 ['fc_value_1[0][0]']
fc_out (Dense) (None, 5) 1285 ['fc_2[0][0]']
value_out (Dense) (None, 1) 257 ['fc_value_2[0][0]']
==================================================================================================
Total params: 137,222
Trainable params: 137,222
Non-trainable params: 0https://stackoverflow.com/questions/70573735
复制相似问题