@@ -248,7 +248,9 @@ def get(self, epochs=1):
248248 label_dict_train = {"dummy_loss" : []}
249249 label_dict_val = {"dummy_loss" : []}
250250 for i in range (epochs ):
251- shuffled_indices = np .random .permutation (self .data_state .x_train .shape [0 ])
251+ shuffled_indices = paddle .randperm (
252+ n = self .data_state .x_train .shape [0 ]
253+ ).numpy ()
252254 input_dict_train ["state_x" ].append (
253255 self .data_state .x_train [shuffled_indices [0 : self .itrain ]]
254256 )
@@ -263,7 +265,7 @@ def get(self, epochs=1):
263265 )
264266 label_dict_train ["dummy_loss" ].append (0.0 )
265267
266- shuffled_indices = np . random . permutation ( self .data_state .x_valid .shape [0 ])
268+ shuffled_indices = paddle . randperm ( n = self .data_state .x_valid .shape [0 ]). numpy ( )
267269 input_dict_val ["state_x" ].append (
268270 self .data_state .x_valid [shuffled_indices [0 : self .itrain ]]
269271 )
@@ -296,7 +298,7 @@ def __init__(self, dataset_path, train_p=0.6, cross_valid_p=0.2, test_p=0.2):
296298 def get_shuffled_data (self ):
297299 # Need to set the seed, otherwise the loss will not match the precision
298300 ppsci .utils .misc .set_random_seed (seed = 10 )
299- shuffled_indices = np . random . permutation ( self .x .shape [0 ])
301+ shuffled_indices = paddle . randperm ( n = self .x .shape [0 ]). numpy ( )
300302 n_train = math .floor (self .train_p * self .x .shape [0 ])
301303 n_cross_valid = math .floor (self .cross_valid_p * self .x .shape [0 ])
302304 n_test = math .floor (self .test_p * self .x .shape [0 ])
0 commit comments