def __init__(self, vocab, arch, normalization='none', activation='relu', padding='same', vecs_size=1024, pooling='avg'): super(AppearanceEncoder, self).__init__() self.vocab = vocab cnn_kwargs = { 'arch': arch, 'normalization': normalization, 'activation': activation, 'pooling': pooling, 'padding': padding, } cnn, channels = build_cnn(**cnn_kwargs) self.cnn = nn.Sequential(cnn, GlobalAvgPool(), nn.Linear(channels, vecs_size))
def __init__(self, vocab, arch, normalization='none', activation='relu', padding='same', pooling='avg'): super(AcDiscriminator, self).__init__() self.vocab = vocab cnn_kwargs = { 'arch': arch, 'normalization': normalization, 'activation': activation, 'pooling': pooling, 'padding': padding, } cnn, D = build_cnn(**cnn_kwargs) self.cnn = nn.Sequential(cnn, GlobalAvgPool(), nn.Linear(D, 1024)) num_objects = len(vocab['object_idx_to_name']) #len(vocab['object_to_idx']) #cm Azade self.real_classifier = nn.Linear(1024, 1) self.obj_classifier = nn.Linear(1024, num_objects)