예제 #1
0
 def load(self, path):
     # dont remove this line. This is important to init the PyTorch nn
     self.init_modules()
     print('loading from: ' + path)
     model = PyTorchAug.load(path)
     print(model)
     return model
예제 #2
0
def test_save_load():
    np.random.seed(123)
    a_np = np.random.randn(3, 2).astype(np.float32)
    a = PyTorch.asFloatTensor(a_np)
    print('a', a)

    filename = '/tmp/foo.t7'  # TODO: should use tempfile to get this
    PyTorchAug.save(filename, a)

    b = PyTorchAug.load(filename)
    print('type(b)', type(b))
    print('b', b)

    assert np.abs(a_np - b.asNumpyTensor()).max() < 1e-4