摘要:
参数过多会导致模型过于复杂而出现过拟合现象,通过在loss函数添加关于参数个数的代价变量,限制参数个数,来达到减小过拟合的目的 以下是loss公式: 代码多了一个kernel_regularizer参数 import tensorflow as tf def preporocess(x,y): x 阅读全文
摘要:
import tensorflow as tf def preprocess(x, y): x = tf.cast(x, dtype=tf.float32) / 255 - 0.5 y = tf.cast(y, dtype=tf.int32) return x, y batchsz = 128 # 阅读全文