aimerykong / OpenGAN

ICCV2021 - training a post-hoc lightweight GAN-discriminator for open-set recognition
119 stars 17 forks source link

Why does the generator use conv2d layers with size 1? #13

Open Kanbe-Kotori opened 10 months ago

Kanbe-Kotori commented 10 months ago

In demo_CrossDatasetOpenSet_training.ipynb [3]:

My understanding of the model is that the output of the Generator should be equal in shape to the output of the classifier (ResNet-18), i.e., a [512, 1, 1] tensor after GAP. In this case, as you said, the actual structure of the Generator is just a MLP. So, what does conv2d layers do? Or to put it another way, if I use a normal network of nn.Linear + nn.BatchNorm1d as a generator, and then reshape the output to a shape of [512, 1, 1], are they equal?

If so, what's your actual meaning of the annotations like "state size: (self.ngf*8) x 4 x 4"? Shouldn't the actual shape of the output of this layer be (self.ngf*8) x 1 x 1?

Looking forward to your reply.

mywsmjj commented 9 months ago

Hello, can I take a look at the OTS characteristics generated by your resnet18 network. If you can know the structure of your resnet18 network, thank you very much and I wish you all the best in your work!

mywsmjj commented 9 months ago

你好,请问我可以看看你的resnet18网络生成的OTS特征吗。如果可以知道您的resnet18网络的结构的话,那万分感谢您,祝您工作顺利!

Kanbe-Kotori commented 9 months ago

你好,请问我可以看看你的resnet18网络生成的OTS特征吗。如果可以知道您的resnet18网络的结构的话,那万分感谢您,祝您工作顺利!

你好,ResNet18的结构是高度固定的,即[2, 2, 2, 2]的BasicBlock->平均池化->FC(输出)。

我理解文章中使用的OTS特征是ResNet18的池化层的输出 self.pooling = nn.Sequential( nn.AdaptiveAvgPool1d(1), nn.Flatten(), ) ,形状为[batchsize, 512]