-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Defense GAN defender #7
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нужно доработать, оставил комментарии
self.noise_size = noise_size | ||
super().__init__() | ||
self.model = nn.Sequential( | ||
nn.Linear(100, 256), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
наверное тут должно быть nn.Linear(noise_size, 256)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
256 лучше не хардкодить, а дать пользователю возможность указать
noise_size: int = 256): | ||
self.num_sensors = num_sensors | ||
self.window_size = window_size | ||
self.noise_size = noise_size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
зачем хранить размер шума? он вроде нигде не используется
nn.LeakyReLU(True), | ||
nn.Linear(256, 256), | ||
nn.LeakyReLU(True), | ||
nn.Linear(256, 256), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
количество слоев лучше тоже указывать в параметре
return self.model(x).view(-1, self.window_size, self.num_sensors) | ||
|
||
|
||
class Discriminator(nn.Module): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
аналогичные комментарии как и для генератора. добавить число слоев и размерность в виде параметров
return self.model(x) | ||
|
||
|
||
class DefenseGanDefender(BaseDefender): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не очень удачное название, два раза повторяется слово defense. пусть будет просто GANDefender
return self.model.predict(np.stack(approximations)) | ||
|
||
|
||
# GRU version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не надо добавлять комментарии между классами
|
||
# GRU version | ||
|
||
class SelectItem(nn.Module): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
что это за класс? для чего он нужен?
self.noise_size = noise_size | ||
super().__init__() | ||
self.model = nn.Sequential( | ||
nn.GRU(self.noise_size, 128, num_layers=1, batch_first=True), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
128 не надо харкодить, вынести в параметры
return self.model(x) | ||
|
||
|
||
class GRUDiscriminator(nn.Module): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
128 не надо харкодить, вынести в параметры
return self.model(x) | ||
|
||
|
||
class GRUDefenseGanDefender(BaseDefender): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
в чем отличие этого класса от DefenseGANDefender? если только в том что разные архитектуры генератора и дискриминатора, то лучше это внутри одного класса сделать.
Cr.: Иван Галкин, Иван Конюшенко, Александр Срибняк, Ренат Харисов