Tensorflow 中 1D 的 SSIM 损失

问题描述

TensorFlow 有一个 image ssim,但没有用于 1D(结构相似性指数度量 - SSIM)。

在查看 tf.image.ssimgit hub 后,将其更改为 1D 看起来并不容易。为了尝试按原样使用 tf.image.ssim,我尝试重塑并添加另一个维度(因为“窗口”默认为 11)。这是我的初步尝试:

def SSIMLoss(y_true,y_pred):
  y_pred = np.array(y_pred).astype('float16')
  y_pred = y_pred.reshape(y_pred.shape + (1,))

  y_true = np.array(y_true).astype('float16')
  y_true = y_true.reshape(y_true.shape + (1,))

  y_true_final = y_true.copy()
  y_pred_final = y_pred.copy()
  for i in range(10):
    y_true_final = np.vstack((y_true_final,y_true))
    y_pred_final = np.vstack((y_pred_final,y_pred))

  return 1 - tf.image.ssim(y_true_final,y_pred_final,1.0)

如果您将单个 1D DataFrame 传递给它,这会起作用。

我已经尝试调整它,以便我可以将其用作实际的损失函数,但是传入的 TF 张量无法移动到数组中,因为它位于图形中(并且所有尝试都没有成功) .有没有更简单的方法来做到这一点,或者我最好从头开始编写 1D ssim(以及我将如何使用 TF 张量来做到这一点)?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...