Browse Source

Alexnet模型添加选择嵌入层方法

liyan 1 year ago
parent
commit
4da8633c6d
1 changed files with 10 additions and 0 deletions
  1. 10 0
      model/Alexnet.py

+ 10 - 0
model/Alexnet.py

@@ -58,6 +58,16 @@ class Alexnet(nn.Module):
         x = self.classifier(x)
         x = self.classifier(x)
         return x
         return x
 
 
+    def get_encode_layers(self):
+        """
+        获取用于白盒模型水印加密层,每个模型根据复杂度选择合适的卷积层
+        """
+        conv_list = []
+        for module in self.modules():
+            if isinstance(module, nn.Conv2d):
+                conv_list.append(module)
+        return conv_list[0:2]
+
 if __name__ == '__main__':
 if __name__ == '__main__':
     import argparse
     import argparse