Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Tensorflow 不推荐使用Keras模型/层正则化特性_Tensorflow_Keras - Fatal编程技术网

Tensorflow 不推荐使用Keras模型/层正则化特性

Tensorflow 不推荐使用Keras模型/层正则化特性,tensorflow,keras,Tensorflow,Keras,我使用Keras来定义一个模型,然后我尝试使用分布式Tensorflow来校准它,就像这样做的 我以前处理正则化器的丢失,就像在链接中一样 model = Sequential() ...... #build keras model loss = tf.reduce_mean(keras.objectives.mean_squared_error(targets, preds)) # apply regularizers if any if model.regularizers: tot

我使用Keras来定义一个模型,然后我尝试使用分布式Tensorflow来校准它,就像这样做的

我以前处理正则化器的丢失,就像在链接中一样

model = Sequential()
...... #build keras model
loss = tf.reduce_mean(keras.objectives.mean_squared_error(targets, preds))
# apply regularizers if any
if model.regularizers:
    total_loss = loss * 1.  # copy tensor
    for regularizer in model.regularizers:
        total_loss = regularizer(total_loss)
else:
    total_loss = loss
但是现在正则化器属性已被去除润滑,并且有一条警告建议使用
模型/层的
损失
属性
,因此我尝试:

 loss = tf.reduce_mean(keras.objectives.mean_squared_error(targets, preds))
 total_loss = loss * 1.  # copy tensor
 for reg_loss in model.losses:
     tf.assign_add(total_loss, reg_loss)

但这会导致崩溃。请提供任何帮助

正确的做法是:

loss = tf.reduce_mean(keras.objectives.mean_squared_error(targets, preds))
total_loss = loss * 1.  # copy tensor
for reg_loss in model.losses:
total_loss = total8loss + reg_loss

什么是撞车?有消息要发吗?