Caffe2 - Python API
A deep learning, cross platform ML framework
tests_setup.py
1 import sys
2 import os
3 import torch
4 
5 testEvalModeForLoadedModule_module_path = 'dropout_model.pt'
6 
7 
8 def testEvalModeForLoadedModule_setup():
9  class Model(torch.jit.ScriptModule):
10  def __init__(self):
11  super(Model, self).__init__()
12  self.dropout = torch.nn.Dropout(0.1)
13 
14  def forward(self, x):
15  x = self.dropout(x)
16  return x
17 
18  model = Model()
19  model = model.train()
20  model.save(testEvalModeForLoadedModule_module_path)
21 
22 
23 def testEvalModeForLoadedModule_shutdown():
24  if os.path.exists(testEvalModeForLoadedModule_module_path):
25  os.remove(testEvalModeForLoadedModule_module_path)
26 
27 
28 def setup():
29  testEvalModeForLoadedModule_setup()
30 
31 
32 def shutdown():
33  testEvalModeForLoadedModule_shutdown()
34 
35 
36 if __name__ == "__main__":
37  command = sys.argv[1]
38  if command == "setup":
39  setup()
40  elif command == "shutdown":
41  shutdown()
Definition: setup.py:1