Open-Debin / Emotion-FAN

ICIP 2019: Frame Attention Networks for Facial Expression Recognition in Videos
MIT License
337 stars 76 forks source link

IndexError: too many indices for tensor of dimension 4 #20

Open HCookY95 opened 3 years ago

HCookY95 commented 3 years ago

@Open-Debin 求问答主,我用您的model resnet18_FAN,有这样的报错是怎么回事?

f = x[:, :, :, :, i] IndexError: too many indices for tensor of dimension 4

Open-Debin commented 3 years ago

Hi,

The tensor is shaped in [batch, channel, height, width, N_segment ]

The code is designed for processing video data, where the input of the FAN model is N_segment x frames, each frame is a 4-dimensional tensor, therefore N_segment x frames is a 5-dimensional tensor. If you input a 4-dimensional tensor, the error must happen.

HCookY95 commented 3 years ago

Hi,

The tensor is shaped in [batch, channel, height, width, N_segment ]

The code is designed for processing video data, where the input of the FAN model is N_segment x frames, each frame is a 4-dimensional tensor, therefore N_segment x frames is a 5-dimensional tensor. If you input a 4-dimensional tensor, the error must happen.

请问作者有邮箱或者微信吗,能否私下询问一下?

HCookY95 commented 3 years ago

Hi,

The tensor is shaped in [batch, channel, height, width, N_segment ]

The code is designed for processing video data, where the input of the FAN model is N_segment x frames, each frame is a 4-dimensional tensor, therefore N_segment x frames is a 5-dimensional tensor. If you input a 4-dimensional tensor, the error must happen.

@Open-Debin 我删掉了num_pair=3的参数,在train中只执行一次,就没有这个报错了。 但是执行自己的main file以后出现了NoneType has no attribute data。这是我自己定义的一个梯度裁剪的function。

def clip_gradient(optimizer, grad_clip): for group in optimizer.param_groups: for param in group['params']: param.grad.data.clamp_(-grad_clip, grad_clip) print (param.grad)

然后我print了一下每层的weight和bias,发现self.beta和self.pred_fc2这两层没有参数,没法进行反向传播,所以直接在ResNet_AT里comment了这两层,请问这样做是对的吗,还是因为这两层在network里detached了,我应该用什么方式连进去?

for name, param in model.named_parameters(): print(name, param.grad)

另外,没有再报错了,不过CK+的准确率卡在了93-94之间,是因为上面提到的问题,还是我应该尝试一些其他的lr scheduler?

Open-Debin commented 3 years ago

@HCookY95 Merry Christmas! I recently update the Emotion-FAN, new features include data process, environment install, CK+ code, and Baseline code. Also, you can find the old version directory of Emotion-FAN in the README.md. I hope my new updates can help you greatly. Please see the Emotion-FAN for more details.