test <- tryCatch({
lrelu(layer_output)
TRUE
}, error=function(e){
print(paste("error in lrelu:infinite weights/bias,try end early"))
FALSE
})
if (test) {#print(c(i,layer_input,weights,biases,layer_output,layer_inputs,layer_outputs))
怀疑是lrelu(layer_output)出了问题,所以在函数代码里加上tryCatch(),可以在报错的同时print一些需要的信息