0
我將numpy數組的字典保存到pickle文件。然後取消它們到新的變量。代碼是這樣的:Python - 保存到Pickle文件中的數據類型保留
酸洗:
# here the variables 'train_dataset', 'train_labels' etc are all np arrays.
save = {
'train_dataset': train_dataset,
'train_labels': train_labels,
'valid_dataset': valid_dataset,
'valid_labels': valid_labels,
'test_dataset': test_dataset,
'test_labels': test_labels,
}
pickle.dump(save, f, pickle.HIGHEST_PROTOCOL)
取儲存:
save = pickle.load(f)
train_dataset_new = save['train_dataset']
train_labels_new = save['train_labels']
valid_dataset_new = save['valid_dataset']
valid_labels_new = save['valid_labels']
test_dataset_new = save['test_dataset']
test_labels_new = save['test_labels']
將從泡菜文件中加載的變量也是NP陣列?如果可以的話,請詳細說明一下。
感謝