我的代码
fig,ax = plt.subplots(rows,cols, figsize = [24,24])
plt.subplots_adjust(hspace=0, wspace=0)
for i in range(cols):
step = 6
ind = i*step
ax[0,i].imshow(a[ind,:,:],cmap='gray')
ax[0,i].axis('off')
ax[1,i].imshow(b[ind,:,:],cmap='gray')
ax[1,i].axis('off')
ax[2,i].imshow(c[ind,:,:],cmap='gray')
ax[2,i].axis('off')
Run Code Online (Sandbox Code Playgroud)
然而,似乎 plt.subplots_adjust(hspace=0, wspace=0) 根本不起作用。我注意到它强制图形具有相同的 x 和 y 大小,你能帮我纠正这个问题吗?
尝试在 keras 中自定义损失函数(平滑 L1 损失),如下所示
ValueError: Shape must be rank 0 but is rank 5 for 'cond/Switch' (op: 'Switch') with input shape: [?,24,24,24,?], [?,24,24,24,? ]。
from keras import backend as K
import numpy as np
def smooth_L1_loss(y_true, y_pred):
THRESHOLD = K.variable(1.0)
mae = K.abs(y_true-y_pred)
flag = K.greater(mae, THRESHOLD)
loss = K.mean(K.switch(flag, (mae - 0.5), K.pow(mae, 2)), axis=-1)
return loss
Run Code Online (Sandbox Code Playgroud)