x_train.flush()

发布时间 2023-05-26 10:52:50作者: 辛宣
        if not os.path.exists(PATH + 'x_train.npy'):
            x_train = np.memmap(PATH + 'x_train.npy', dtype=cfg['data_type'], mode='w+', shape=(
            self.time_length_f - N, self.nlat_f, self.nlon_f, self.num_features_f + self.num_features_l))
            x_train[:, :, :, :self.num_features_f] = forcing[:self.time_length_f - N]
            x_train[:, :, :, self.num_features_f:] = land_surface[:self.time_length_f - N]
            x_train.flush()
            del x_train

保存操作

在这段代码中,保存操作是通过以下语句完成的:

x_train.flush()

x_train.flush()是将数据写入磁盘的操作。当使用np.memmap创建的数组时,数据并不会立即写入磁盘,而是在调用flush()方法时才会将数据刷新到磁盘上的文件中。