Error while saving my network
I have made a CNN: <SCODE>class convNet(nn.Module):
    #constructor
    def __init__(self):
        super(convNet, self).__init__()
       
        self.conv1 = nn.Conv2d(3, 96, kernel_size=7,stride=1,padding=3)
        self.conv2 = nn.Conv2d(96, 256, kernel_size=5,stride=1,padding=2)
        self.conv3 = nn.Conv2d(256,384,kernel_size=3,stride=1,padding=1)
        self.conv4 = nn.Conv2d(384,512,kernel_size=3,stride=1,padding=1)
        self.conv5 = nn.Conv2d(512,1024,kernel_size=3,stride=1,padding=1)
        self.fc1   = nn.Linear(4*4*1024, 300)
        self.fc2   = nn.Linear(300, 100)
        self.fc3   = nn.Linear(100, 10)
        

    def forward(self, x):
        conv1_relu = nnFunctions.relu(self.conv1(x))
        conv2_relu = nnFunctions.relu(self.conv2(conv1_relu))
        conv3_relu =nnFunctions.max_pool2d(nnFunctions.relu(self.conv3(conv2_relu)),2)
        conv4_relu =nnFunctions.max_pool2d(nnFunctions.relu(self.conv4(conv3_relu)),2)
        conv5_relu =nnFunctions.max_pool2d(nnFunctions.relu(self.conv5(conv4_relu)),2)
    
        x = conv5_relu.view(-1, 4*4*1024)
        x = nnFunctions.relu(self.fc1(x))
        x = nnFunctions.relu(self.fc2(x))
        x = self.fc3(x)
        return x
<ECODE> <SCODE>net=convNet()
net.cuda()
<ECODE> It gives me the following errror: <SCODE>
AttributeError                            Traceback (most recent call last)
<ipython-input-13-a8f33f24049b> in <module>()
----> 1 torch.save('net.t7',net)

/home/sarthak/anaconda2/lib/python2.7/site-packages/torch/serialization.pyc in save(obj, f, pickle_module, pickle_protocol)
    121         f = open(f, "wb")
    122     try:
--> 123         return _save(obj, f, pickle_module, pickle_protocol)
    124     finally:
    125         if new_fd:

/home/sarthak/anaconda2/lib/python2.7/site-packages/torch/serialization.pyc in _save(obj, f, pickle_module, pickle_protocol)
    212         pickle_module.dump(sys_info, f, protocol=pickle_protocol)
    213 
--> 214     with closing(tarfile.open(fileobj=f, mode='w:', format=tarfile.PAX_FORMAT)) as tar:
    215         _add_to_tar(save_sys_info, tar, 'sys_info')
    216         _add_to_tar(pickle_objects, tar, 'pickle')

/home/sarthak/anaconda2/lib/python2.7/tarfile.pyc in open(cls, name, mode, fileobj, bufsize, **kwargs)
   1691             else:
   1692                 raise CompressionError("unknown compression type %r" % comptype)
-> 1693             return func(name, filemode, fileobj, **kwargs)
   1694 
   1695         elif "|" in mode:

/home/sarthak/anaconda2/lib/python2.7/tarfile.pyc in taropen(cls, name, mode, fileobj, **kwargs)
   1721         if mode not in ("r", "a", "w"):
   1722             raise ValueError("mode must be 'r', 'a' or 'w'")
-> 1723         return cls(name, mode, fileobj, **kwargs)
   1724 
   1725     @classmethod

/home/sarthak/anaconda2/lib/python2.7/tarfile.pyc in __init__(self, name, mode, fileobj, format, tarinfo, dereference, ignore_zeros, encoding, errors, pax_headers, debug, errorlevel)
   1577         self.members = []       # list of members as TarInfo objects
   1578         self._loaded = False    # flag if all members have been read
-> 1579         self.offset = self.fileobj.tell()
   1580                                 # current position in the archive file
   1581         self.inodes = {}        # dictionary caching the inodes of

/home/sarthak/anaconda2/lib/python2.7/site-packages/torch/nn/modules/module.pyc in __getattr__(self, name)
    241             if name in modules:
    242                 return modules[name]
--> 243         return object.__getattribute__(self, name)
    244 
    245     def __setattr__(self, name, value):

AttributeError: 'convNet' object has no attribute 'tell'
<ECODE>
sarthak1996
<SCODE>torch.save('net.txt',net)
<ECODE> It is: <SCODE>torch.save(net, 'net.txt')
<ECODE>
smth
Thanks for your help
sarthak1996
<SCODE>/home/sarthak/anaconda2/lib/python2.7/site-packages/torch/serialization.pyc in load(f, map_location, pickle_module)
    246         f = open(f, 'rb')
    247     try:
--> 248         return _load(f, map_location, pickle_module)
    249     finally:
    250         if new_fd:

/home/sarthak/anaconda2/lib/python2.7/site-packages/torch/serialization.pyc in _load(f, map_location, pickle_module)
    344         unpickler = pickle_module.Unpickler(pickle_file)
    345         unpickler.persistent_load = persistent_load
--> 346         result = unpickler.load()
    347         return result

AttributeError: 'module' object has no attribute 'convNet'<ECODE>
sarthak1996
apaszke
sarthak1996
You need to copy the code of your network to that other notebook.
apaszke
Or better put it in a file in the same directory as your notebooks and import it from both.
apaszke