【发布时间】:2018-06-26 11:01:03
【问题描述】:
我正在尝试在 docker 环境中使用 R 脚本对我通过管道传输的输入进行一些分类。
该脚本应该只打印分类的输出,但是我总是得到 Using TensorFlow backend. 作为调用 Keras 函数的第一行的输出。
我做了一个小的工作示例。
library(keras)
v <- (c(1,2,3))
print(v)
vCat<-to_categorical(v)
我想将其显示为输出:
[1] 1 2 3
我明白了
[1] 1 2 3
Using TensorFlow backend.
所以我在 google 和 stackoverflow 上搜索了 sink 和 suppress... 以及其他内容,例如 Suppress automatic output to console in R、Suppress one command's output in R 和 Suppress automatic output to console in R。然后我尝试了以下代码:
library(keras, quietly = T)
v <- (c(1,2,3))
print(v)
sink("/dev/null")
capture.output(suppressMessages(suppressWarnings(
suppressPackageStartupMessages(
vCat<-to_categorical(v) ))), file = "/dev/null")
sink()
这仍然不会抑制Using TensorFlow backend. 消息。该脚本在 docker 环境中使用 littler 从命令行调用:r test.R。
注意:仅在 Rstudio 中运行脚本时,我没有收到消息。
【问题讨论】:
-
不幸的是,这似乎是标准行为,其他人也一直在抱怨,但到目前为止还没有解决方案:"Using X backend." always printed to stdout