【发布时间】:2019-12-26 03:47:09
【问题描述】:
您如何实施conv2d,其中每个过滤器的均值为零。
我尝试通过 conv2d 中的 kernel_regularizer 参数来执行此操作,但由于某种原因遇到了问题。
def zero_mean_regularizer(weight_matrix):
# weight matrix is channel last
return weight_matrix - K.mean(weight_matrix, axis=(1, 2), keepdims=True)
但由于某种原因,我从 ModelCheckpoint 回调中收到了一个神秘错误。
self = <keras.callbacks.ModelCheckpoint object at 0x12e890358>, epoch = 0
logs = {'loss': array([[[[-0.24377288, 0.4010657 , 0.03990834, -0.19173835,
0.02325685, -0.12445911, 0.34307766...0454, 0.18098758, 0.05493904,
-0.15479018, -0.19435076, 0.07913151, 0.20207654]]]],
dtype=float32)}
def on_epoch_end(self, epoch, logs=None):
logs = logs or {}
self.epochs_since_last_save += 1
if self.epochs_since_last_save >= self.period:
self.epochs_since_last_save = 0
filepath = self.filepath.format(epoch=epoch + 1, **logs)
if self.save_best_only:
current = logs.get(self.monitor)
if current is None:
warnings.warn('Can save best model only with %s available, '
'skipping.' % (self.monitor), RuntimeWarning)
else:
> if self.monitor_op(current, self.best):
E ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
似乎这个正则化器导致模型为单个时期创建多个损失值。
【问题讨论】:
标签: python tensorflow keras conv-neural-network