InceptionTime 复现

下载数据集:

https://www.cs.ucr.edu/~eamonn/time_series_data/
挂梯子,开全局模式即可

配置环境

虚拟环境基于python=3.9,
tensorflow下载:pip install tensorflow,不需要tensorflow-gpu(高版本python)
其他零零散散的安装,不用requirements.txt

运行代码

更改数据集路径(根据报错更改)

改成了TSC/datasetsname

keras报错

  1. 根据类似链接 https://stackoverflow.com/questions/68913520/module-keras-layers-normalization-has-no-attribute-batchnormalizationbase改一下(把报错信息贴到google即可)
  2. inception.py 111行
    InceptionTime 复现_第1张图片
    发现是因为tensorflow版本不对(从tf1变成了tf2),但这只是一个检测gpu是否可用,那就换个写法。
  3. tensorflow检测gpu不可用
    InceptionTime 复现_第2张图片
  • 好像是因为,虚拟环境中不能用base的cuda和cudnn?所以又在虚拟环境中安装了
  • 发现还是不行,所以又安装了tensorflow-gpu,使用命令pip install tensorflow-gpu==2.6.0
  • 发现pandas和matplotlib版本太新了,试试tf2.8.0

耶,成功了!
InceptionTime 复现_第3张图片

  1. 因为重新安装了,所以又回到了第一个问题
    InceptionTime 复现_第4张图片
    还是解决from keras.layers.normalization.layer_normalization import * from keras.layers.normalization.batch_normalization import *

  2. https://stackoverflow.com/questions/69334001/attributeerror-module-keras-optimizers-has-no-attribute-adam
    InceptionTime 复现_第5张图片

  3. Could not locate zlibwapi.dll. Please make sure it is in your library path!
    使用https://blog.csdn.net/Chaos_Happy/article/details/124064428

  4. Traceback (most recent call last): File "d:\Coding\GitHub\InceptionTime\main.py", line 138, in fit_classifier() File "d:\Coding\GitHub\InceptionTime\main.py", line 49, in fit_classifier classifier.fit(x_train, y_train, x_test, y_test, y_true) File "d:\Coding\GitHub\InceptionTime\classifiers\nne.py", line 74, in fit curr_y_pred = model.predict(x_test, y_true, x_train, y_train, y_test, File "d:\Coding\GitHub\InceptionTime\classifiers\inception.py", line 156, in predict model = keras.models.load_model(model_path) File "C:\Users\DescFly\anaconda3\envs\Inception\lib\site-packages\keras\utils\traceback_utils.py", line 67, in error_handler raise e.with_traceback(filtered_tb) from None File "C:\Users\DescFly\anaconda3\envs\Inception\lib\site-packages\keras\saving\save.py", line 204, in load_model raise IOError(f'No file or directory found at {filepath_str}') OSError: No file or directory found at D:/Coding/GitHub/InceptionTime/results/inception/TSC/Coffee/best_model.hdf5
    貌似使用命令& C:/Users/DescFly/anaconda3/envs/Inception/python.exe d:/Coding/GitHub/InceptionTime/main.py InceptionTime直接不训练了;怎么训练起来呢?
    InceptionTime 复现_第6张图片
    难道说这个网络不能被训练吗?
    可以的,发现有几行代码,检测当存在文件夹时就跳过训练,我虽然创建了文件夹,但没有训练成功。 if temp_output_directory is None: print('Already_done', tmp_output_directory, dataset_name) continue

  5. np.float改成np.float64

  6. val_acc改为val_accuracy:https://towardsdatascience.com/fixing-the-keyerror-acc-and-keyerror-val-acc-errors-in-keras-2-3-x-or-newer-b29b52609af9

  7. 成功跑起来了!

你可能感兴趣的:(tensorflow,python,深度学习)