Tensorflow2.0默认下载数据集到C盘的修改方法
jupyter(Win版本)下载数据集会默认到C盘下,Linux会默认到root下,修改方式如下·
tf1.x:
import os
import tensorflow as tf
tf.disable_v2_behavior()
tf.enable_eager_execution()
train_dataset_url = "http://download.tensorflow.org/data/iris_training.csv"
train_dataset_fp = tf.keras.utils.get_file(fname='./'+os.path.basename(train_dataset_url),
origin=train_dataset_url, cache_dir='.')
print("Local copy of the dataset file: {}".format(train_dataset_fp))
tf2.0版本:
import os
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
tf.enable_eager_execution()
train_dataset_url = "http://download.tensorflow.org/data/iris_training.csv"
train_dataset_fp = tf.keras.utils.get_file(fname='./'+os.path.basename(train_dataset_url),
origin=train_dataset_url, cache_dir='.')
print("Local copy of the dataset file: {}".format(train_dataset_fp))
这样就会把数据集下载到jupyter工作空间下出现一个datasets的文件夹保存下载的数据而不是跑到C盘,至于如何下载官方数据集更改其路径,研究清楚会更新本文》