【问题标题】:Suppress (hard to catch) output of an R function抑制(难以捕捉)R 函数的输出
【发布时间】:2020-12-26 04:02:24
【问题描述】:

有没有办法抑制R包keras的函数layer_dense()产生的输出? 以下四种变体中的任何一种都会在第一次 layer_dense() 调用中导致以下输出,我想避免这种情况:

2020-12-25 22:52:32.777776: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2020-12-25 22:52:32.792832: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x7f9ca7099490 executing computations on platform Host. Devices:
2020-12-25 22:52:32.792853: I tensorflow/compiler/xla/service/service.cc:175]   StreamExecutor device (0): Host, Default Version

一些试验:

library(keras)
in.lay <- layer_input(shape = 2)
capture.output(out.lay <- layer_dense(in.lay, units = 2))
q()

library(keras)
in.lay <- layer_input(shape = 2)
suppressWarnings(out.lay <- layer_dense(in.lay, units = 2))
q()

library(keras)
in.lay <- layer_input(shape = 2)
suppressMessages(out.lay <- layer_dense(in.lay, units = 2))
q()

library(keras)
in.lay <- layer_input(shape = 2)
suppressPackageStartupMessages(out.lay <- layer_dense(in.lay, units = 2))
q()

This 是相关的,但上述情况似乎更难解决。

【问题讨论】:

    标签: r keras suppress-warnings suppressmessage


    【解决方案1】:

    虽然它不能解决一般问题(但我想尝试过的解决方案应该会起作用),但我现在找到了解决这个特殊问题的方法here 和一点解释here。简而言之,调用Sys.setenv(TF_CPP_MIN_LOG_LEVEL = "1")会避开该消息(并且有0、1、2、3级别可供选择)。

    【讨论】:

      猜你喜欢
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多