MCPcopy
hub / github.com/QData/TextAttack / save

Method save

textattack/shared/checkpoint.py:207–221  ·  view source on GitHub ↗
(self, quiet=False)

Source from the content-addressed store, hash-verified

205 return datetime.datetime.fromtimestamp(self.time).strftime("%Y-%m-%d %H:%M:%S")
206
207 def save(self, quiet=False):
208 file_name = "{}.ta.chkpt".format(int(self.time * 1000))
209 if not os.path.exists(self.attack_args.checkpoint_dir):
210 os.makedirs(self.attack_args.checkpoint_dir)
211 path = os.path.join(self.attack_args.checkpoint_dir, file_name)
212 if not quiet:
213 print("\n\n" + "=" * 125)
214 logger.info(
215 'Saving checkpoint under "{}" at {} after {} attacks.'.format(
216 path, self.datetime, self.results_count
217 )
218 )
219 print("=" * 125 + "\n")
220 with open(path, "wb") as f:
221 pickle.dump(self, f, protocol=pickle.HIGHEST_PROTOCOL)
222
223 @classmethod
224 def load(cls, path):

Callers 5

_attackMethod · 0.95
_attack_parallelMethod · 0.95
save_pretrainedMethod · 0.80
save_pretrainedMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected