跑通tsc从这个项目的过程中,我认识到了虚拟环境相当于一个真实的计算机环境,python、git、cuda和cudNN都可以在虚拟环境中安装。这样就不会出现tf1.14环境改tf2.0的环境过程中,需要重新安装对应的cuda和cudnn的问题。
1. 在github上面下载tsc这个项目
下载地址:https://github.com/hfawaz/dl-4-tsc
2.下载tsc从这个项目对应的数据集
数据集列表:http://www.timeseriesclassification.com/dataset.php
数据集下载地址:https://www.cs.ucr.edu/~eamonn/time_series_data_2018/UCRArchive_2018.zip 解压密码:smoeone
3.创建跑tsc的虚拟环境
安装anaconda
创建虚拟环境: conda create -n tf2.0 python=3.6
激活虚拟环境: conda activate tf2.0
安装GPU需要的cuda和cudnn: conda install cudatoolkit=10.0 cudnn
安装tenserflowgpu2.0:pip install tensorflow-gpu==2.0.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
cd到下一级目录utils:cd untils
由于我们装过tenserflow了,将pip-requirements.txt中tenserflow_gpu注释掉,
h5py要指定安装2.8版本:加上版本号h5py=2.8 或者pip install h5py==2.8.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
安装pip-requirements.txt中的包:pip-requirements.txtpip install -r pip-requirements.txt
pip-requirements.txt中注释掉的内容,
4.在pycharm中跑通
安装pycharm,pycharm续命的一个好用的工具。工具地址:https://shimo.im/docs/ckprWXRyDcTydv6t/read
创建一个project,为这个project配置tf2.0 这个解释器.
project目录中创建一个名为archive的文件夹用来放训练数据UCRArchive_2018,就是第二步下载的数据集。
将下载好的项目解压放到,新创建的项目中,相同的文件名直接替换。
修改root_dir为当前project的目录。
将运行参数改为UCRArchive_2018 Coffee fcn _itr_8
run 最后得到的结果是Done没有任何报错。
5. 多变量数据集的载入
说明地址:https://github.com/alan-turing-institute/sktime/blob/main/examples/loading_data.ipynb
来自ARFF文件中的多变量数量数据读取到SKTime格式。
pip install sktime
from sktime.utils.data_io import load_from_arff_to_dataframe
X, y = load_from_arff_to_dataframe(
os.path.join(DATA_PATH, "BasicMotions/BasicMotions_TRAIN.arff")
)
X.head()
ps:我用的是梯子,没有梯子需要重新设置channl。