项目场景:
试图加入一个新的loss函数
问题描述:
在加入新的loss进行计算的时候碰到如标题所示的bug
原因分析:
原因是没有实例化网络,直接调用类来进行forward
import torch
import torch.nn as nn
import torch.nn.functional as F
import math
from torchvision.models.vgg import vgg16
import numpy as np
'''Zero-DCE Spatial Consistency Loss'''
class L_spa(nn.Module):
def __init__(self):
super(L_spa, self).__init__()
# print(1)kernel = torch.FloatTensor(kernel).unsqueeze(0).unsqueeze(0)
kernel_left = torch.FloatTensor( [[0,0,0],[-1,1,0],[0,0,0]]).cuda().unsqueeze(0).unsqueeze(0)
kernel_right = torch.FloatTensor( [[0,0,0],[0,