Closed joehalfish closed 4 years ago
Hi, if you want to change the value of k in the scripts that train the networks, you can change the lines percent=100/num_images to percent=k/num_images, where k is your desired value for k. Please let me know if that worked for you.
Thanks , I will have a try .
发自我的iPhone
------------------ Original ------------------ From: Carlos Rodríguez - Pardo <notifications@github.com> Date: Tue,Dec 24,2019 8:27 PM To: crp94/Personalised-aesthetic-assessment-using-residual-adapters <Personalised-aesthetic-assessment-using-residual-adapters@noreply.github.com> Cc: joehalfish <601269914@qq.com>, Author <author@noreply.github.com> Subject: Re: [crp94/Personalised-aesthetic-assessment-using-residual-adapters] how can i set the K ? (#3)
Hi, if you want to change the value of k in the scripts that train the networks, you can change the lines percent=100/num_images to percent=k/num_images, where k is your desired value for k. Please let me know if that worked for you.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
Sorry to bother you again, I found that there is another parameter K1. How do I change the value of K1? Is it to change the number of adapters in rsn18?
I assume you are referring to the K1 parameter in Figure 1 in the paper: https://link.springer.com/chapter/10.1007%2F978-3-030-31332-6_44
This value modifies the number of convolutional filters in each adapter. We did not submit the code for such setup, as it did not work better than the baseline, but to implement them, you could substitute the current code for the adapters from (for instance):
self.adapter3_1=nn.Conv2d(K,K, kernel_size=1, padding=0)
To a sequential set of conv2d layers:
self.adapter3_1_input=nn.Conv2d(K, K1, kernel_size=1, padding=0)
self.adapter3_1_k1=nn.Conv2d(K1, K1, kernel_size=1, padding=0)
self.adapter3_1_output=nn.Conv2d(K1, K, kernel_size=1, padding=0)
This should work for you. Be aware that you will need to change every adapter in the network and the forward
method in the resnet model.
I have also updated the Adapters file, it was not the file that was used for the experiments. Sorry for the inconvenience. Now it should be the correct one. Thanks for making me aware of this issue.
You mean, if I make k1 = 1
self.adapter1_0 = nn.Conv2d(64, 64, kernel_size=1, padding=0)
to
self.adapter1_0 = nn.Conv2d(1, 64, kernel_size=1, padding=0)
i am so sorry to ask you again , If you can, I hope you can post the modified code, please。
it's so kind of you ! thanks
The value of K1 is the number of learnable 1x1 filters in each adapter. For preserving the shape matching between input and output of each adapter, if you want to change the number of filters in the adapter to a number that does not match the input/output shapes, you need to modify slightly the structure of the adapter. So for example, if your convolutional layer has is a conv2d(16,16) , it is a layer that expects 16 channels and outputs 16 channels. Thus, your adapter for that layer must also expect 16 channels and output 16 channels. If you want to use a k1 which is not 16, you need to change the structure of the adapter from (for instance):
self.adapter3_1=nn.Conv2d(16,16, kernel_size=1, padding=0)
To a sequential set of conv2d layers:
self.adapter3_1_input=nn.Conv2d(K, K1, kernel_size=1, padding=0)
self.adapter3_1_k1=nn.Conv2d(K1, K1, kernel_size=1, padding=0)
self.adapter3_1_output=nn.Conv2d(K1, K, kernel_size=1, padding=0)
You will also need to change the forward method of the model. So instead of:
x = self.layer3[0].conv2(x) + self.adapter3_1(x)
You can do:
x = self.layer3[0].conv1(x) + self.adapter3_1_output(self.adapter3_1_k1(adapter3_1_input(x)))
You can do this for all the adapters in the network that you want to modify.
This trick is done only for avoiding a shape mismatch between the conv layer and the adapter. More details on this are on our paper and on my masters dissertation, both linked in this repository.
PD: I am sorry I cannot provide the full code for this particular set of experiments. As a reminder, modifying the value of K1 performs worse than the baseline, so there is no real need to do so except for research purposes. Our belief is that reducing the number of filters in the adapters under-parametrizes the user-specific part of the neural network, thus making the model unable to learn valuable information.
More technical details on residual adapters can be found in http://openaccess.thecvf.com/content_cvpr_2018/papers/Rebuffi_Efficient_Parametrization_of_CVPR_2018_paper.pdf and https://arxiv.org/pdf/1705.08045.pdf . The original code for them is in https://github.com/srebuffi/residual_adapters/blob/master/train_new_task_adapters.py .
I hope this was helpful.
You mean i can get the best results in the articlei by following your current code. ok ,Thank you for your tireless help
If you need it, the baseline trained network can be downloaded from here https://drive.google.com/file/d/1030lZOL43_tWl0j8fXpzKO965ll1aQRj/view?usp=sharing
thank you
i have another question.I used the parameters in your paper, batchsize = 30, epoch = 100, but did not achieve your effect. N = 100 adapt.late 0.937, but i got 0.844. N = 100 adapt.all 0.941, but i got 0.833. ths
Hi again! Please make sure that you used the correct architecture for the adapters (use the latest notebook), and that you are evaluating the adapters correctly. Also, check all the data generation process, and that the weight initialisation for the adapters, training rules, learning rates... match our architecture. The numbers you mentioned are the highest spearman correlation for all the users in the test dataset in unseen images. It refers to the user in which our model was most accurate. A more accurate way of measuring the overall results of the algorithm are the median correlations. The minimum and maximum values can be somewhat noisy.
I am a newer and have no idea to set the k in this script . would you mind showing me the best performed script ?thanks !