R:如何舍入 plot.nn() 中的权重数字?

R: how to round weights digits in plot.nn()?

我正在尝试绘制我的神经网络,我想知道如何将权重四舍五入到 3 位数。

library(neuralnet)
set.seed(0)

x = matrix(rnorm(100, 0, 5), ncol=4)
y = rnorm(25, 100, 20)
data = data.frame(y, x)
nn.model = neuralnet(y~., data, linear.output=T, stepmax = 1e+06)

plot(nn.model)

我试过 mapply(round) 但它在 neuralnet 模型生成的列表中没有成功。任何建议表示赞赏!

像这样:

nn.model$weights[[1]] <- lapply(nn.model$weights[[1]], function(x) round(x, 3))
plot(nn.model)