示例#1
0
 def processed_files(self):
     if touch(lambda: self._processed_files, None):
         return self._processed_files
     if self.processed_folder.isdir():
         temp = self.processed_folder.ls()
         while len(temp) == 1 and temp[0].isdir():
             temp = temp[0].ls()
         self._processed_files = temp
     else:
         self._processed_files = vector()
     return self._processed_files
示例#2
0
 def _to_byte__default__(data):
     try:
         import torch
         import pyctlib.torchplus as torchplus
     except ImportError:
         pass
     if touch(lambda: isinstance(data, torchplus.Tensor)):
         np_array = data.cpu().detach().numpy()
         np_array_content, np_array_content_len = file._to_byte(np_array)
         assert len(np_array_content) == np_array_content_len
         return file.Tensor_plus + np_array_content, np_array_content_len + 1
     if touch(lambda: isinstance(data, torch.Tensor)):
         np_array = data.cpu().detach().numpy()
         np_array_content, np_array_content_len = file._to_byte(np_array)
         assert len(np_array_content) == np_array_content_len
         return file.torch_Tensor + np_array_content, np_array_content_len + 1
     if touch(lambda: isinstance(data, torch.nn.Module)):
         module_state_content, module_state_content_len = file._to_byte(
             data.state_dict())
         return file.torch_Module + module_state_content, module_state_content_len + 1
示例#3
0
 def extra_repr(self) -> str:
     if self.activation is None:
         return 'in_features={}, out_features={}, bias={}'.format(self.in_features, self.out_features, self.bias is not None)
     elif isinstance(self.activation, vector):
         ret = 'in_features={}, out_features={}, bias={}, activation={}\n'.format(self.in_features, self.out_features, self.bias is not None, self.activation.map(lambda x: touch(lambda: x.__name__, str(x))))
         ret += "{}".format(self.in_features)
         for d, a in zip(self.dims[1:], self.activation):
             ret += '->{}->{}'.format(d, touch(lambda: a.__name__, str(a)))
         return ret
     else:
         ret = 'in_features={}, out_features={}, bias={}, activation={}'.format(self.in_features, self.out_features, self.bias is not None, touch(lambda: self.activation.__name__, str(self.activation)))
         return ret
示例#4
0
 def name(self):
     if touch(lambda: self._name):
         return self._name
     return self.__class__.__name__
示例#5
0
 def raw_files(self):
     if touch(lambda: self._raw_files, None):
         return self._raw_files
     if self.raw_folder.isdir():
         self._raw_files = self.raw_folder.ls()
         return self._raw_files