Skip to content

Commit 3b16d7a

Browse files
committed
add uuid for ckpt path
1 parent 21857af commit 3b16d7a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

graphgallery/gallery/graph_model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import torch
33
import os
44
import sys
5+
import uuid
56

67
import numpy as np
78
import tensorflow as tf
@@ -65,9 +66,8 @@ def __init__(self, graph, device="cpu", seed=None, name=None, **kwargs):
6566
self._custom_objects = None # used for save/load TF model
6667

6768
# checkpoint path
68-
# add random integer to avoid duplication
69-
_id = np.random.RandomState(None).randint(100)
70-
self.ckpt_path = osp.join(os.getcwd(), f"{self.name}_checkpoint_{_id}{gg.file_ext()}")
69+
# use `uuid` to avoid duplication
70+
self.ckpt_path = osp.join(os.getcwd(), f"{self.name}_checkpoint_{uuid.uuid1().hex[:6]}{gg.file_ext()}")
7171

7272
def save(self,
7373
path=None,

0 commit comments

Comments
 (0)