Skip to content
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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

sribnyak
Copy link

@sribnyak sribnyak commented Jul 31, 2024

Cr.: Иван Галкин, Иван Конюшенко, Александр Срибняк, Ренат Харисов

Copy link
Collaborator

@vpozdnyakov vpozdnyakov left a 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),
Copy link
Collaborator

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)

Copy link
Collaborator

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
Copy link
Collaborator

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),
Copy link
Collaborator

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):
Copy link
Collaborator

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):
Copy link
Collaborator

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
Copy link
Collaborator

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):
Copy link
Collaborator

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),
Copy link
Collaborator

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):
Copy link
Collaborator

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):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в чем отличие этого класса от DefenseGANDefender? если только в том что разные архитектуры генератора и дискриминатора, то лучше это внутри одного класса сделать.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants