diff --git a/Number-Of-CNN-Layers/Five/logs/20230322-203935/train/events.out.tfevents.1679488780.WEIYUQING.18964.0.v2 b/Number-Of-CNN-Layers/Five/logs/20230322-203935/train/events.out.tfevents.1679488780.WEIYUQING.18964.0.v2 new file mode 100644 index 0000000..f8dd0cc Binary files /dev/null and b/Number-Of-CNN-Layers/Five/logs/20230322-203935/train/events.out.tfevents.1679488780.WEIYUQING.18964.0.v2 differ diff --git a/Number-Of-CNN-Layers/Five/logs/20230322-203935/validation/events.out.tfevents.1679488788.WEIYUQING.18964.1.v2 b/Number-Of-CNN-Layers/Five/logs/20230322-203935/validation/events.out.tfevents.1679488788.WEIYUQING.18964.1.v2 new file mode 100644 index 0000000..41be53e Binary files /dev/null and b/Number-Of-CNN-Layers/Five/logs/20230322-203935/validation/events.out.tfevents.1679488788.WEIYUQING.18964.1.v2 differ diff --git a/Number-Of-CNN-Layers/Five/logs/20230323-124459/train/events.out.tfevents.1679546705.WEIYUQING.2708.0.v2 b/Number-Of-CNN-Layers/Five/logs/20230323-124459/train/events.out.tfevents.1679546705.WEIYUQING.2708.0.v2 new file mode 100644 index 0000000..9d81109 Binary files /dev/null and b/Number-Of-CNN-Layers/Five/logs/20230323-124459/train/events.out.tfevents.1679546705.WEIYUQING.2708.0.v2 differ diff --git a/Number-Of-CNN-Layers/Five/logs/20230323-124459/validation/events.out.tfevents.1679546716.WEIYUQING.2708.1.v2 b/Number-Of-CNN-Layers/Five/logs/20230323-124459/validation/events.out.tfevents.1679546716.WEIYUQING.2708.1.v2 new file mode 100644 index 0000000..6126d8f Binary files /dev/null and b/Number-Of-CNN-Layers/Five/logs/20230323-124459/validation/events.out.tfevents.1679546716.WEIYUQING.2708.1.v2 differ diff --git a/Number-Of-CNN-Layers/Five/logs/20230323-131820/train/events.out.tfevents.1679548703.WEIYUQING.3532.0.v2 b/Number-Of-CNN-Layers/Five/logs/20230323-131820/train/events.out.tfevents.1679548703.WEIYUQING.3532.0.v2 new file mode 100644 index 0000000..2465b97 Binary files /dev/null and b/Number-Of-CNN-Layers/Five/logs/20230323-131820/train/events.out.tfevents.1679548703.WEIYUQING.3532.0.v2 differ diff --git a/Number-Of-CNN-Layers/Five/logs/20230323-131820/validation/events.out.tfevents.1679548708.WEIYUQING.3532.1.v2 b/Number-Of-CNN-Layers/Five/logs/20230323-131820/validation/events.out.tfevents.1679548708.WEIYUQING.3532.1.v2 new file mode 100644 index 0000000..5cbad2a Binary files /dev/null and b/Number-Of-CNN-Layers/Five/logs/20230323-131820/validation/events.out.tfevents.1679548708.WEIYUQING.3532.1.v2 differ diff --git a/Number-Of-CNN-Layers/Five/logs/20230323-132426/train/events.out.tfevents.1679549069.WEIYUQING.21724.0.v2 b/Number-Of-CNN-Layers/Five/logs/20230323-132426/train/events.out.tfevents.1679549069.WEIYUQING.21724.0.v2 new file mode 100644 index 0000000..1969ba8 Binary files /dev/null and b/Number-Of-CNN-Layers/Five/logs/20230323-132426/train/events.out.tfevents.1679549069.WEIYUQING.21724.0.v2 differ diff --git a/Number-Of-CNN-Layers/Five/logs/20230323-132426/validation/events.out.tfevents.1679549074.WEIYUQING.21724.1.v2 b/Number-Of-CNN-Layers/Five/logs/20230323-132426/validation/events.out.tfevents.1679549074.WEIYUQING.21724.1.v2 new file mode 100644 index 0000000..143d97e Binary files /dev/null and b/Number-Of-CNN-Layers/Five/logs/20230323-132426/validation/events.out.tfevents.1679549074.WEIYUQING.21724.1.v2 differ diff --git a/Number-Of-CNN-Layers/Five/model/ecg_model_five_layer.h5 b/Number-Of-CNN-Layers/Five/model/ecg_model_five_layer.h5 new file mode 100644 index 0000000..7d075f4 Binary files /dev/null and b/Number-Of-CNN-Layers/Five/model/ecg_model_five_layer.h5 differ diff --git a/Number-Of-CNN-Layers/Five/model/ecg_model_one_layer.h5 b/Number-Of-CNN-Layers/Five/model/ecg_model_one_layer.h5 deleted file mode 100644 index 820134e..0000000 Binary files a/Number-Of-CNN-Layers/Five/model/ecg_model_one_layer.h5 and /dev/null differ diff --git a/Number-Of-CNN-Layers/Five/picture/accuracy.png b/Number-Of-CNN-Layers/Five/picture/accuracy.png index 6f39057..38e8196 100644 Binary files a/Number-Of-CNN-Layers/Five/picture/accuracy.png and b/Number-Of-CNN-Layers/Five/picture/accuracy.png differ diff --git a/Number-Of-CNN-Layers/Five/picture/confusion_matrix.png b/Number-Of-CNN-Layers/Five/picture/confusion_matrix.png index 9f3ed2e..8d3ec4a 100644 Binary files a/Number-Of-CNN-Layers/Five/picture/confusion_matrix.png and b/Number-Of-CNN-Layers/Five/picture/confusion_matrix.png differ diff --git a/Number-Of-CNN-Layers/Five/picture/loss.png b/Number-Of-CNN-Layers/Five/picture/loss.png index 872c937..f2bc33f 100644 Binary files a/Number-Of-CNN-Layers/Five/picture/loss.png and b/Number-Of-CNN-Layers/Five/picture/loss.png differ diff --git a/Number-Of-CNN-Layers/Four/logs/20230323-124456/train/events.out.tfevents.1679546702.WEIYUQING.1944.0.v2 b/Number-Of-CNN-Layers/Four/logs/20230323-124456/train/events.out.tfevents.1679546702.WEIYUQING.1944.0.v2 new file mode 100644 index 0000000..a9b41ec Binary files /dev/null and b/Number-Of-CNN-Layers/Four/logs/20230323-124456/train/events.out.tfevents.1679546702.WEIYUQING.1944.0.v2 differ diff --git a/Number-Of-CNN-Layers/Four/logs/20230323-124456/validation/events.out.tfevents.1679546711.WEIYUQING.1944.1.v2 b/Number-Of-CNN-Layers/Four/logs/20230323-124456/validation/events.out.tfevents.1679546711.WEIYUQING.1944.1.v2 new file mode 100644 index 0000000..749d8e6 Binary files /dev/null and b/Number-Of-CNN-Layers/Four/logs/20230323-124456/validation/events.out.tfevents.1679546711.WEIYUQING.1944.1.v2 differ diff --git a/Number-Of-CNN-Layers/Four/logs/20230323-131110/train/events.out.tfevents.1679548273.WEIYUQING.12052.0.v2 b/Number-Of-CNN-Layers/Four/logs/20230323-131110/train/events.out.tfevents.1679548273.WEIYUQING.12052.0.v2 new file mode 100644 index 0000000..fdc1f7a Binary files /dev/null and b/Number-Of-CNN-Layers/Four/logs/20230323-131110/train/events.out.tfevents.1679548273.WEIYUQING.12052.0.v2 differ diff --git a/Number-Of-CNN-Layers/Four/logs/20230323-131110/validation/events.out.tfevents.1679548278.WEIYUQING.12052.1.v2 b/Number-Of-CNN-Layers/Four/logs/20230323-131110/validation/events.out.tfevents.1679548278.WEIYUQING.12052.1.v2 new file mode 100644 index 0000000..2d9a2c2 Binary files /dev/null and b/Number-Of-CNN-Layers/Four/logs/20230323-131110/validation/events.out.tfevents.1679548278.WEIYUQING.12052.1.v2 differ diff --git a/Number-Of-CNN-Layers/Four/model/ecg_model_four_layer.h5 b/Number-Of-CNN-Layers/Four/model/ecg_model_four_layer.h5 new file mode 100644 index 0000000..d3bf871 Binary files /dev/null and b/Number-Of-CNN-Layers/Four/model/ecg_model_four_layer.h5 differ diff --git a/Number-Of-CNN-Layers/Four/model/ecg_model_one_layer.h5 b/Number-Of-CNN-Layers/Four/model/ecg_model_one_layer.h5 deleted file mode 100644 index 6eea2fb..0000000 Binary files a/Number-Of-CNN-Layers/Four/model/ecg_model_one_layer.h5 and /dev/null differ diff --git a/Number-Of-CNN-Layers/Four/picture/accuracy.png b/Number-Of-CNN-Layers/Four/picture/accuracy.png index fcde6f7..c64f650 100644 Binary files a/Number-Of-CNN-Layers/Four/picture/accuracy.png and b/Number-Of-CNN-Layers/Four/picture/accuracy.png differ diff --git a/Number-Of-CNN-Layers/Four/picture/confusion_matrix.png b/Number-Of-CNN-Layers/Four/picture/confusion_matrix.png index 1753198..d03000e 100644 Binary files a/Number-Of-CNN-Layers/Four/picture/confusion_matrix.png and b/Number-Of-CNN-Layers/Four/picture/confusion_matrix.png differ diff --git a/Number-Of-CNN-Layers/Four/picture/loss.png b/Number-Of-CNN-Layers/Four/picture/loss.png index ff8221e..6d0f608 100644 Binary files a/Number-Of-CNN-Layers/Four/picture/loss.png and b/Number-Of-CNN-Layers/Four/picture/loss.png differ diff --git a/Number-Of-CNN-Layers/One/logs/20230323-124006/train/events.out.tfevents.1679546408.WEIYUQING.9772.0.v2 b/Number-Of-CNN-Layers/One/logs/20230323-124006/train/events.out.tfevents.1679546408.WEIYUQING.9772.0.v2 new file mode 100644 index 0000000..536aff3 Binary files /dev/null and b/Number-Of-CNN-Layers/One/logs/20230323-124006/train/events.out.tfevents.1679546408.WEIYUQING.9772.0.v2 differ diff --git a/Number-Of-CNN-Layers/One/logs/20230323-124006/validation/events.out.tfevents.1679546410.WEIYUQING.9772.1.v2 b/Number-Of-CNN-Layers/One/logs/20230323-124006/validation/events.out.tfevents.1679546410.WEIYUQING.9772.1.v2 new file mode 100644 index 0000000..6c0596c Binary files /dev/null and b/Number-Of-CNN-Layers/One/logs/20230323-124006/validation/events.out.tfevents.1679546410.WEIYUQING.9772.1.v2 differ diff --git a/Number-Of-CNN-Layers/One/model/ecg_model_one_layer.h5 b/Number-Of-CNN-Layers/One/model/ecg_model_one_layer.h5 index cebc7fa..4f23fea 100644 Binary files a/Number-Of-CNN-Layers/One/model/ecg_model_one_layer.h5 and b/Number-Of-CNN-Layers/One/model/ecg_model_one_layer.h5 differ diff --git a/Number-Of-CNN-Layers/One/picture/accuracy.png b/Number-Of-CNN-Layers/One/picture/accuracy.png index ac6246d..9e224f4 100644 Binary files a/Number-Of-CNN-Layers/One/picture/accuracy.png and b/Number-Of-CNN-Layers/One/picture/accuracy.png differ diff --git a/Number-Of-CNN-Layers/One/picture/confusion_matrix.png b/Number-Of-CNN-Layers/One/picture/confusion_matrix.png index 3f72435..e51a28d 100644 Binary files a/Number-Of-CNN-Layers/One/picture/confusion_matrix.png and b/Number-Of-CNN-Layers/One/picture/confusion_matrix.png differ diff --git a/Number-Of-CNN-Layers/One/picture/loss.png b/Number-Of-CNN-Layers/One/picture/loss.png index b8ae0fa..e8ef0e9 100644 Binary files a/Number-Of-CNN-Layers/One/picture/loss.png and b/Number-Of-CNN-Layers/One/picture/loss.png differ diff --git a/Number-Of-CNN-Layers/Three/logs/20230323-124453/train/events.out.tfevents.1679546699.WEIYUQING.18768.0.v2 b/Number-Of-CNN-Layers/Three/logs/20230323-124453/train/events.out.tfevents.1679546699.WEIYUQING.18768.0.v2 new file mode 100644 index 0000000..5eea640 Binary files /dev/null and b/Number-Of-CNN-Layers/Three/logs/20230323-124453/train/events.out.tfevents.1679546699.WEIYUQING.18768.0.v2 differ diff --git a/Number-Of-CNN-Layers/Three/logs/20230323-124453/validation/events.out.tfevents.1679546707.WEIYUQING.18768.1.v2 b/Number-Of-CNN-Layers/Three/logs/20230323-124453/validation/events.out.tfevents.1679546707.WEIYUQING.18768.1.v2 new file mode 100644 index 0000000..07d7a9b Binary files /dev/null and b/Number-Of-CNN-Layers/Three/logs/20230323-124453/validation/events.out.tfevents.1679546707.WEIYUQING.18768.1.v2 differ diff --git a/Number-Of-CNN-Layers/Three/logs/20230323-125405/train/events.out.tfevents.1679547249.WEIYUQING.7488.0.v2 b/Number-Of-CNN-Layers/Three/logs/20230323-125405/train/events.out.tfevents.1679547249.WEIYUQING.7488.0.v2 new file mode 100644 index 0000000..9fdf386 Binary files /dev/null and b/Number-Of-CNN-Layers/Three/logs/20230323-125405/train/events.out.tfevents.1679547249.WEIYUQING.7488.0.v2 differ diff --git a/Number-Of-CNN-Layers/Three/logs/20230323-125405/validation/events.out.tfevents.1679547253.WEIYUQING.7488.1.v2 b/Number-Of-CNN-Layers/Three/logs/20230323-125405/validation/events.out.tfevents.1679547253.WEIYUQING.7488.1.v2 new file mode 100644 index 0000000..8a48e42 Binary files /dev/null and b/Number-Of-CNN-Layers/Three/logs/20230323-125405/validation/events.out.tfevents.1679547253.WEIYUQING.7488.1.v2 differ diff --git a/Number-Of-CNN-Layers/Three/logs/20230323-130741/train/events.out.tfevents.1679548064.WEIYUQING.25804.0.v2 b/Number-Of-CNN-Layers/Three/logs/20230323-130741/train/events.out.tfevents.1679548064.WEIYUQING.25804.0.v2 new file mode 100644 index 0000000..e8ad3c1 Binary files /dev/null and b/Number-Of-CNN-Layers/Three/logs/20230323-130741/train/events.out.tfevents.1679548064.WEIYUQING.25804.0.v2 differ diff --git a/Number-Of-CNN-Layers/Three/logs/20230323-130741/validation/events.out.tfevents.1679548068.WEIYUQING.25804.1.v2 b/Number-Of-CNN-Layers/Three/logs/20230323-130741/validation/events.out.tfevents.1679548068.WEIYUQING.25804.1.v2 new file mode 100644 index 0000000..b5e5a40 Binary files /dev/null and b/Number-Of-CNN-Layers/Three/logs/20230323-130741/validation/events.out.tfevents.1679548068.WEIYUQING.25804.1.v2 differ diff --git a/Number-Of-CNN-Layers/Three/model/ecg_model_one_layer.h5 b/Number-Of-CNN-Layers/Three/model/ecg_model_one_layer.h5 deleted file mode 100644 index e4a45ce..0000000 Binary files a/Number-Of-CNN-Layers/Three/model/ecg_model_one_layer.h5 and /dev/null differ diff --git a/Number-Of-CNN-Layers/Three/model/ecg_model_three_layer.h5 b/Number-Of-CNN-Layers/Three/model/ecg_model_three_layer.h5 new file mode 100644 index 0000000..c4c0519 Binary files /dev/null and b/Number-Of-CNN-Layers/Three/model/ecg_model_three_layer.h5 differ diff --git a/Number-Of-CNN-Layers/Three/picture/accuracy.png b/Number-Of-CNN-Layers/Three/picture/accuracy.png index 86fa783..f4801c9 100644 Binary files a/Number-Of-CNN-Layers/Three/picture/accuracy.png and b/Number-Of-CNN-Layers/Three/picture/accuracy.png differ diff --git a/Number-Of-CNN-Layers/Three/picture/confusion_matrix.png b/Number-Of-CNN-Layers/Three/picture/confusion_matrix.png index d7bfee9..bdea210 100644 Binary files a/Number-Of-CNN-Layers/Three/picture/confusion_matrix.png and b/Number-Of-CNN-Layers/Three/picture/confusion_matrix.png differ diff --git a/Number-Of-CNN-Layers/Three/picture/loss.png b/Number-Of-CNN-Layers/Three/picture/loss.png index eab8e35..b7c4f65 100644 Binary files a/Number-Of-CNN-Layers/Three/picture/loss.png and b/Number-Of-CNN-Layers/Three/picture/loss.png differ diff --git a/Number-Of-CNN-Layers/Two/logs/20230323-124448/train/events.out.tfevents.1679546693.WEIYUQING.7948.0.v2 b/Number-Of-CNN-Layers/Two/logs/20230323-124448/train/events.out.tfevents.1679546693.WEIYUQING.7948.0.v2 new file mode 100644 index 0000000..c90e393 Binary files /dev/null and b/Number-Of-CNN-Layers/Two/logs/20230323-124448/train/events.out.tfevents.1679546693.WEIYUQING.7948.0.v2 differ diff --git a/Number-Of-CNN-Layers/Two/logs/20230323-124448/validation/events.out.tfevents.1679546699.WEIYUQING.7948.1.v2 b/Number-Of-CNN-Layers/Two/logs/20230323-124448/validation/events.out.tfevents.1679546699.WEIYUQING.7948.1.v2 new file mode 100644 index 0000000..4353bb5 Binary files /dev/null and b/Number-Of-CNN-Layers/Two/logs/20230323-124448/validation/events.out.tfevents.1679546699.WEIYUQING.7948.1.v2 differ diff --git a/Number-Of-CNN-Layers/Two/model/ecg_model_one_layer.h5 b/Number-Of-CNN-Layers/Two/model/ecg_model_one_layer.h5 deleted file mode 100644 index f8a8096..0000000 Binary files a/Number-Of-CNN-Layers/Two/model/ecg_model_one_layer.h5 and /dev/null differ diff --git a/Number-Of-CNN-Layers/Two/model/ecg_model_two_layer.h5 b/Number-Of-CNN-Layers/Two/model/ecg_model_two_layer.h5 new file mode 100644 index 0000000..b57a42a Binary files /dev/null and b/Number-Of-CNN-Layers/Two/model/ecg_model_two_layer.h5 differ diff --git a/Number-Of-CNN-Layers/Two/picture/accuracy.png b/Number-Of-CNN-Layers/Two/picture/accuracy.png index 2833fc1..93b26ee 100644 Binary files a/Number-Of-CNN-Layers/Two/picture/accuracy.png and b/Number-Of-CNN-Layers/Two/picture/accuracy.png differ diff --git a/Number-Of-CNN-Layers/Two/picture/confusion_matrix.png b/Number-Of-CNN-Layers/Two/picture/confusion_matrix.png index 93986d6..8488702 100644 Binary files a/Number-Of-CNN-Layers/Two/picture/confusion_matrix.png and b/Number-Of-CNN-Layers/Two/picture/confusion_matrix.png differ diff --git a/Number-Of-CNN-Layers/Two/picture/loss.png b/Number-Of-CNN-Layers/Two/picture/loss.png index ba5d299..9c136f9 100644 Binary files a/Number-Of-CNN-Layers/Two/picture/loss.png and b/Number-Of-CNN-Layers/Two/picture/loss.png differ diff --git a/Number-Of-CNN-Layers/_mian_tensorflow_fiveLayerCNN.py b/Number-Of-CNN-Layers/_mian_tensorflow_fiveLayerCNN.py index 570967e..9db5c22 100644 --- a/Number-Of-CNN-Layers/_mian_tensorflow_fiveLayerCNN.py +++ b/Number-Of-CNN-Layers/_mian_tensorflow_fiveLayerCNN.py @@ -13,7 +13,7 @@ from utils_fiveLayerCNN import loadData, plot_history_tf, plot_heat_map Project_PATH = "../Number-Of-CNN-Layers/Five/" #PICTUREPATH= Project_PATH + "picture/" log_dir = Project_PATH + "logs/" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S") -model_Path_one = Project_PATH + "model/ecg_model_one_layer.h5" +model_Path_one = Project_PATH + "model/ecg_model_five_layer.h5" #model_Path_one = Project_PATH + "ecg_model_one_layer.h5" RATIO = 0.3 diff --git a/Number-Of-CNN-Layers/_mian_tensorflow_fourLayerCNN.py b/Number-Of-CNN-Layers/_mian_tensorflow_fourLayerCNN.py index 4702d82..12bd1cd 100644 --- a/Number-Of-CNN-Layers/_mian_tensorflow_fourLayerCNN.py +++ b/Number-Of-CNN-Layers/_mian_tensorflow_fourLayerCNN.py @@ -13,7 +13,7 @@ from utils_fourLayerCNN import loadData, plot_history_tf, plot_heat_map Project_PATH = "../Number-Of-CNN-Layers/Four/" #PICTUREPATH= Project_PATH + "picture/" log_dir = Project_PATH + "logs/" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S") -model_Path_one = Project_PATH + "model/ecg_model_one_layer.h5" +model_Path_one = Project_PATH + "model/ecg_model_four_layer.h5" #model_Path_one = Project_PATH + "ecg_model_one_layer.h5" RATIO = 0.3 diff --git a/Number-Of-CNN-Layers/_mian_tensorflow_threeLayerCNN.py b/Number-Of-CNN-Layers/_mian_tensorflow_threeLayerCNN.py index b1d1aa2..1092846 100644 --- a/Number-Of-CNN-Layers/_mian_tensorflow_threeLayerCNN.py +++ b/Number-Of-CNN-Layers/_mian_tensorflow_threeLayerCNN.py @@ -13,7 +13,7 @@ from utils_threeLayerCNN import loadData, plot_history_tf, plot_heat_map Project_PATH = "../Number-Of-CNN-Layers/Three/" #PICTUREPATH= Project_PATH + "picture/" log_dir = Project_PATH + "logs/" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S") -model_Path_one = Project_PATH + "model/ecg_model_one_layer.h5" +model_Path_one = Project_PATH + "model/ecg_model_three_layer.h5" #model_Path_one = Project_PATH + "ecg_model_one_layer.h5" RATIO = 0.3 diff --git a/Number-Of-CNN-Layers/_mian_tensorflow_twoLayerCNN.py b/Number-Of-CNN-Layers/_mian_tensorflow_twoLayerCNN.py index 35106ae..50f883d 100644 --- a/Number-Of-CNN-Layers/_mian_tensorflow_twoLayerCNN.py +++ b/Number-Of-CNN-Layers/_mian_tensorflow_twoLayerCNN.py @@ -13,7 +13,7 @@ from utils_twoLayerCNN import loadData, plot_history_tf, plot_heat_map Project_PATH = "../Number-Of-CNN-Layers/Two/" #PICTUREPATH= Project_PATH + "picture/" log_dir = Project_PATH + "logs/" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S") -model_Path_one = Project_PATH + "model/ecg_model_one_layer.h5" +model_Path_one = Project_PATH + "model/ecg_model_two_layer.h5" #model_Path_one = Project_PATH + "ecg_model_one_layer.h5" RATIO = 0.3 diff --git a/Number-Of-Conv-Structure/Four/logs/20230323-121744/train/events.out.tfevents.1679545068.WEIYUQING.25044.0.v2 b/Number-Of-Conv-Structure/Four/logs/20230323-121744/train/events.out.tfevents.1679545068.WEIYUQING.25044.0.v2 new file mode 100644 index 0000000..81ac8b6 Binary files /dev/null and b/Number-Of-Conv-Structure/Four/logs/20230323-121744/train/events.out.tfevents.1679545068.WEIYUQING.25044.0.v2 differ diff --git a/Number-Of-Conv-Structure/Four/logs/20230323-121744/validation/events.out.tfevents.1679545072.WEIYUQING.25044.1.v2 b/Number-Of-Conv-Structure/Four/logs/20230323-121744/validation/events.out.tfevents.1679545072.WEIYUQING.25044.1.v2 new file mode 100644 index 0000000..2a1098f Binary files /dev/null and b/Number-Of-Conv-Structure/Four/logs/20230323-121744/validation/events.out.tfevents.1679545072.WEIYUQING.25044.1.v2 differ diff --git a/Number-Of-Conv-Structure/Three/logs/20230322-205453/train/events.out.tfevents.1679489695.WEIYUQING.21588.0.v2 b/Number-Of-Conv-Structure/Three/logs/20230322-205453/train/events.out.tfevents.1679489695.WEIYUQING.21588.0.v2 new file mode 100644 index 0000000..4e94640 Binary files /dev/null and b/Number-Of-Conv-Structure/Three/logs/20230322-205453/train/events.out.tfevents.1679489695.WEIYUQING.21588.0.v2 differ diff --git a/Number-Of-Conv-Structure/Three/logs/20230322-205453/validation/events.out.tfevents.1679489698.WEIYUQING.21588.1.v2 b/Number-Of-Conv-Structure/Three/logs/20230322-205453/validation/events.out.tfevents.1679489698.WEIYUQING.21588.1.v2 new file mode 100644 index 0000000..bdea2af Binary files /dev/null and b/Number-Of-Conv-Structure/Three/logs/20230322-205453/validation/events.out.tfevents.1679489698.WEIYUQING.21588.1.v2 differ diff --git a/Number-Of-Conv-Structure/Three/logs/20230322-205716/train/events.out.tfevents.1679489838.WEIYUQING.28036.0.v2 b/Number-Of-Conv-Structure/Three/logs/20230322-205716/train/events.out.tfevents.1679489838.WEIYUQING.28036.0.v2 new file mode 100644 index 0000000..fab97a8 Binary files /dev/null and b/Number-Of-Conv-Structure/Three/logs/20230322-205716/train/events.out.tfevents.1679489838.WEIYUQING.28036.0.v2 differ diff --git a/Number-Of-Conv-Structure/Three/logs/20230322-205716/validation/events.out.tfevents.1679489840.WEIYUQING.28036.1.v2 b/Number-Of-Conv-Structure/Three/logs/20230322-205716/validation/events.out.tfevents.1679489840.WEIYUQING.28036.1.v2 new file mode 100644 index 0000000..1fb16b3 Binary files /dev/null and b/Number-Of-Conv-Structure/Three/logs/20230322-205716/validation/events.out.tfevents.1679489840.WEIYUQING.28036.1.v2 differ diff --git a/Number-Of-Conv-Structure/Three/logs/20230322-205854/train/events.out.tfevents.1679489936.WEIYUQING.3384.0.v2 b/Number-Of-Conv-Structure/Three/logs/20230322-205854/train/events.out.tfevents.1679489936.WEIYUQING.3384.0.v2 new file mode 100644 index 0000000..6a5b068 Binary files /dev/null and b/Number-Of-Conv-Structure/Three/logs/20230322-205854/train/events.out.tfevents.1679489936.WEIYUQING.3384.0.v2 differ diff --git a/Number-Of-Conv-Structure/Three/logs/20230322-205854/validation/events.out.tfevents.1679489938.WEIYUQING.3384.1.v2 b/Number-Of-Conv-Structure/Three/logs/20230322-205854/validation/events.out.tfevents.1679489938.WEIYUQING.3384.1.v2 new file mode 100644 index 0000000..dfd52bc Binary files /dev/null and b/Number-Of-Conv-Structure/Three/logs/20230322-205854/validation/events.out.tfevents.1679489938.WEIYUQING.3384.1.v2 differ diff --git a/Number-Of-Conv-Structure/Three/model/ecg_model_one_layer.h5 b/Number-Of-Conv-Structure/Three/model/ecg_model_one_layer.h5 new file mode 100644 index 0000000..63bd1b8 Binary files /dev/null and b/Number-Of-Conv-Structure/Three/model/ecg_model_one_layer.h5 differ diff --git a/Number-Of-Conv-Structure/Three/picture/accuracy.png b/Number-Of-Conv-Structure/Three/picture/accuracy.png new file mode 100644 index 0000000..51fb5fa Binary files /dev/null and b/Number-Of-Conv-Structure/Three/picture/accuracy.png differ diff --git a/Number-Of-Conv-Structure/Three/picture/confusion_matrix.png b/Number-Of-Conv-Structure/Three/picture/confusion_matrix.png new file mode 100644 index 0000000..6ad31ce Binary files /dev/null and b/Number-Of-Conv-Structure/Three/picture/confusion_matrix.png differ diff --git a/Number-Of-Conv-Structure/Three/picture/loss.png b/Number-Of-Conv-Structure/Three/picture/loss.png new file mode 100644 index 0000000..cfe4c88 Binary files /dev/null and b/Number-Of-Conv-Structure/Three/picture/loss.png differ diff --git a/Number-Of-Conv-Structure/_mian_tensorflow_Four_ConvCNN.py b/Number-Of-Conv-Structure/_mian_tensorflow_Four_ConvCNN.py new file mode 100644 index 0000000..81d540f --- /dev/null +++ b/Number-Of-Conv-Structure/_mian_tensorflow_Four_ConvCNN.py @@ -0,0 +1,81 @@ +import datetime +import os + +import numpy as np +import pywt +import wfdb +import tensorflow as tf +from tensorflow import keras +from utils_four_of_ConvCNN import loadData, plot_history_tf, plot_heat_map + +#from ECG_read_weiyuqing_without_wfdb import ECGDATAPATH +#PATH of this test +Project_PATH = "../Number-Of-Conv-Structure/Four/" +#PICTUREPATH= Project_PATH + "picture/" +log_dir = Project_PATH + "logs/" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S") +model_Path_one = Project_PATH + "model/ecg_model_four_conv.h5" +#model_Path_one = Project_PATH + "ecg_model_one_layer.h5" + +RATIO = 0.3 +RANDOM_SEED = 42 +BATCH_SIZE = 128 +#迭代次数 +NUM_EPOCHS = 10 + + +def CNN_model_level_one(): + leavlOneModel = tf.keras.models.Sequential([ + + #take test for one CNN layers model + + tf.keras.layers.InputLayer(input_shape=(300, 1)), + + tf.keras.layers.Conv1D(filters=1, kernel_size=4, strides=1, padding='same', activation='relu'), + tf.keras.layers.MaxPool1D(pool_size=1, strides=2, padding='same'), + + + + tf.keras.layers.Flatten(), + tf.keras.layers.Dense(128, activation='relu'), + # add dropout layer, dropout rate = 0.2 + tf.keras.layers.Dropout(rate=0.2), + tf.keras.layers.Dense(5, activation='softmax') + ]) + return leavlOneModel + + +def main(): + # get traxin test + X_train, X_test, y_train, y_test = loadData(RATIO, RANDOM_SEED) + + # get model or create model + if os.path.exists(model_Path_one): + print(' get model in h5 file') + model = tf.keras.models.load_model(filepath=model_Path_one) + else: + # create new model(if model unexists) + model = CNN_model_level_one() + model.compile(optimizer='adam', + loss='sparse_categorical_crossentropy', + metrics=['accuracy']) + model.summary() + # TB make + tensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir=log_dir, + histogram_freq=1, + ) + # Training and validation + history = model.fit(X_train, y_train, epochs=NUM_EPOCHS, + batch_size=BATCH_SIZE, + validation_data=(X_test, y_test), + callbacks=[tensorboard_callback]) + # validation_split=RATIO, + model.save(filepath=model_Path_one) + plot_history_tf(history) + + y_pred = np.argmax(model.predict(X_test), axis=-1) + plot_heat_map(y_test, y_pred) + + +if __name__ == '__main__': + os.environ["CUDA_VISIBLE_DEVICES"] = "-1" + main() diff --git a/Number-Of-Conv-Structure/_mian_tensorflow_Three_ConvCNN.py b/Number-Of-Conv-Structure/_mian_tensorflow_Three_ConvCNN.py new file mode 100644 index 0000000..1b76280 --- /dev/null +++ b/Number-Of-Conv-Structure/_mian_tensorflow_Three_ConvCNN.py @@ -0,0 +1,81 @@ +import datetime +import os + +import numpy as np +import pywt +import wfdb +import tensorflow as tf +from tensorflow import keras +from utils_three_of_ConvCNN import loadData, plot_history_tf, plot_heat_map + +#from ECG_read_weiyuqing_without_wfdb import ECGDATAPATH +#PATH of this test +Project_PATH = "../Number-Of-Conv-Structure/Three/" +#PICTUREPATH= Project_PATH + "picture/" +log_dir = Project_PATH + "logs/" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S") +model_Path_one = Project_PATH + "model/ecg_model_three_conv.h5" +#model_Path_one = Project_PATH + "ecg_model_one_layer.h5" + +RATIO = 0.3 +RANDOM_SEED = 42 +BATCH_SIZE = 128 +#迭代次数 +NUM_EPOCHS = 10 + + +def CNN_model_level_one(): + leavlOneModel = tf.keras.models.Sequential([ + + #take test for one CNN layers model + + tf.keras.layers.InputLayer(input_shape=(300, 1)), + + tf.keras.layers.Conv1D(filters=1, kernel_size=3, strides=1, padding='same', activation='relu'), + tf.keras.layers.MaxPool1D(pool_size=1, strides=2, padding='same'), + + + + tf.keras.layers.Flatten(), + tf.keras.layers.Dense(128, activation='relu'), + # add dropout layer, dropout rate = 0.2 + tf.keras.layers.Dropout(rate=0.2), + tf.keras.layers.Dense(5, activation='softmax') + ]) + return leavlOneModel + + +def main(): + # get traxin test + X_train, X_test, y_train, y_test = loadData(RATIO, RANDOM_SEED) + + # get model or create model + if os.path.exists(model_Path_one): + print(' get model in h5 file') + model = tf.keras.models.load_model(filepath=model_Path_one) + else: + # create new model(if model unexists) + model = CNN_model_level_one() + model.compile(optimizer='adam', + loss='sparse_categorical_crossentropy', + metrics=['accuracy']) + model.summary() + # TB make + tensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir=log_dir, + histogram_freq=1, + ) + # Training and validation + history = model.fit(X_train, y_train, epochs=NUM_EPOCHS, + batch_size=BATCH_SIZE, + validation_data=(X_test, y_test), + callbacks=[tensorboard_callback]) + # validation_split=RATIO, + model.save(filepath=model_Path_one) + plot_history_tf(history) + + y_pred = np.argmax(model.predict(X_test), axis=-1) + plot_heat_map(y_test, y_pred) + + +if __name__ == '__main__': + os.environ["CUDA_VISIBLE_DEVICES"] = "-1" + main() diff --git a/Number-Of-Conv-Structure/utils_four_of_ConvCNN.py b/Number-Of-Conv-Structure/utils_four_of_ConvCNN.py new file mode 100644 index 0000000..4f1c3d0 --- /dev/null +++ b/Number-Of-Conv-Structure/utils_four_of_ConvCNN.py @@ -0,0 +1,172 @@ +# this file give +import os + +import wfdb +import pywt +import seaborn +import numpy as np +import matplotlib.pyplot as plt +from sklearn.metrics import confusion_matrix +from sklearn.model_selection import train_test_split + +# from _mian_tensorflow import Project_PATH +Project_PATH = '../Number-Of-Conv-Structure/Four/' + +PICTUREPATH = Project_PATH + 'picture/' + +# from ECG_read_weiyuqing_without_wfdb import ECGDATAPATH +MITBITECGDATAPATH = '../MIT-BIT/' + + +# wavelet denoise preprocess using mallat algorithm + +def denoise(date): + # Wavelet db5 level9 + coeffs = pywt.wavedec(data=date, wavelet='db5', level=9) + cA9, cD9, cD8, cD7, cD6, cD5, cD4, cD3, cD2, cD1 = coeffs + # noice del + threshold = (np.median(np.abs(cD1)) / 0.6745) * (np.sqrt(2 * np.log(len(cD1)))) + # take cD 1,2 turn 0 to denoise + cD1.fill(0) + cD2.fill(0) + for i in range(1, len(coeffs) - 2): + coeffs[i] = pywt.threshold(coeffs[i], threshold) + # get signal that before wavelet + rdata = pywt.waverec(coeffs=coeffs, wavelet='db5') + return rdata + + +# get ECG data,date type and denoise +# this function without return +# use append take return data to pass data +def getDataSet(number, X_data, Y_data): + ecgClassSet = ['N', 'A', 'V', 'L', 'R'] + print('get' + number + ' ECG data') + record = wfdb.rdrecord(MITBITECGDATAPATH + number, channel_names=['MLII']) + data = record.p_signal.flatten() + # use def denoise + rdata = denoise(date=data) + + # get type of ECG data + annotation = wfdb.rdann(MITBITECGDATAPATH + number, 'atr') + Rlocation = annotation.sample # annotation.sample:get R + Rclass = annotation.symbol + + # delete stable date near R + start = 10 + end = 5 + i = start + j = len(annotation.symbol) - end + + # get NAVLR type data + while i < j: + try: + lable = ecgClassSet.index(Rclass[i]) + x_train = rdata[Rlocation[i] - 99:Rlocation[i] + 201] + X_data.append(x_train) + Y_data.append(lable) + i += 1 + except ValueError: + i += 1 + return + + +# RATIO=The ratio of the training set to the test set,usually is 0.3 +def loadData(ratio, random_seed): + numberSet = ['100', '101', '103', '105', '106', '107', '108', '109', '111', '112', '113', '114', '115', + '116', '117', '119', '121', '122', '123', '124', '200', '201', '202', '203', '205', '208', + '210', '212', '213', '214', '215', '217', '219', '220', '221', '222', '223', '228', '230', + '231', '232', '233', '234'] + dataSet = [] + labelSet = [] + for n in numberSet: + getDataSet(n, dataSet, labelSet) + + # dataSet = np.array(dataSet).reshape(-1, 300) + # labelSet = np.array(labelSet).reshape(-1, 1) + + # reshape the data and split the dataset + dataSet = np.array(dataSet).reshape(-1, 300) + lableSet = np.array(labelSet).reshape(-1) + X_train, X_test, y_train, y_test = train_test_split(dataSet, lableSet, test_size=ratio, random_state=random_seed) + # print(X_train, X_test, y_train, y_test) + return X_train, X_test, y_train, y_test + + # train_ds = np.hstack((dataSet, labelSet)) + # np.random.shuffle(train_ds) + # + # X = train_ds[:, :300].reshape(-1, 300, 1) + # Y = train_ds[:, 300] + # # cut test and train data from ECG data + # shuffle_index = np.random.permutation(len(X)) + # test_length = int(RATIO * len(shuffle_index)) + # test_index = shuffle_index[:test_length] + # train_index = shuffle_index[test_index:] + # X_test, Y_test = X[test_index:], Y[test_index] + # X_train, Y_train = X[train_index], Y[train_index] + # return X_train, Y_test, X_test, Y_train + + +# confusion matrix +def plot_heat_map(y_test, y_pred): + con_mat = confusion_matrix(y_test, y_pred) + # normalize + # con_mat_norm = con_mat.astype('float') / con_mat.sum(axis=1)[:, np.newaxis] + # con_mat_norm = np.around(con_mat_norm, decimals=2) + # os.remove(PICTUREPATH+'confusion_matrix.png') + # plot + plt.figure(figsize=(8, 8)) + seaborn.heatmap(con_mat, annot=True, fmt='.20g', cmap='Blues') + plt.ylim(0, 5) + plt.xlabel('Predicted labels') + plt.ylabel('True labels') + plt.title('Confusion Matrix') + plt.savefig(PICTUREPATH + 'confusion_matrix.png') + plt.show() + + +def plot_history_tf(history): + # os.remove(PICTUREPATH+'accuracy.png') + # os.remove(PICTUREPATH+'loss.png') + + plt.figure(figsize=(8, 8)) + plt.plot(history.history['accuracy']) + plt.plot(history.history['val_accuracy']) + plt.title('Model Accuracy') + plt.ylabel('Accuracy') + plt.xlabel('Epoch') + plt.legend(['Train', 'Test'], loc='upper left') + plt.savefig(PICTUREPATH + 'accuracy.png') + plt.show() + + plt.figure(figsize=(8, 8)) + plt.plot(history.history['loss']) + plt.plot(history.history['val_loss']) + plt.title('Model Loss') + plt.ylabel('Loss') + plt.xlabel('Epoch') + plt.legend(['Train', 'Test'], loc='upper left') + plt.savefig(PICTUREPATH + 'loss.png') + plt.show() + + +def plot_history_torch(history): + plt.figure(figsize=(8, 8)) + plt.plot(history['train_acc']) + plt.plot(history['test_acc']) + plt.title('Model Accuracy') + plt.ylabel('Accuracy') + plt.xlabel('Epoch') + plt.legend(['Train', 'Test'], loc='upper left') + plt.savefig(PICTUREPATH + 'accuracy.png') + plt.show() + + plt.figure(figsize=(8, 8)) + plt.plot(history['train_loss']) + plt.plot(history['test_loss']) + plt.title('Model Loss') + plt.ylabel('Loss') + plt.xlabel('Epoch') + plt.legend(['Train', 'Test'], loc='upper left') + plt.savefig(PICTUREPATH + 'loss.png') + plt.show() diff --git a/Number-Of-Conv-Structure/utils_three_of_ConvCNN.py b/Number-Of-Conv-Structure/utils_three_of_ConvCNN.py new file mode 100644 index 0000000..1bc9798 --- /dev/null +++ b/Number-Of-Conv-Structure/utils_three_of_ConvCNN.py @@ -0,0 +1,172 @@ +# this file give +import os + +import wfdb +import pywt +import seaborn +import numpy as np +import matplotlib.pyplot as plt +from sklearn.metrics import confusion_matrix +from sklearn.model_selection import train_test_split + +# from _mian_tensorflow import Project_PATH +Project_PATH = '../Number-Of-Conv-Structure/Three/' + +PICTUREPATH = Project_PATH + 'picture/' + +# from ECG_read_weiyuqing_without_wfdb import ECGDATAPATH +MITBITECGDATAPATH = '../MIT-BIT/' + + +# wavelet denoise preprocess using mallat algorithm + +def denoise(date): + # Wavelet db5 level9 + coeffs = pywt.wavedec(data=date, wavelet='db5', level=9) + cA9, cD9, cD8, cD7, cD6, cD5, cD4, cD3, cD2, cD1 = coeffs + # noice del + threshold = (np.median(np.abs(cD1)) / 0.6745) * (np.sqrt(2 * np.log(len(cD1)))) + # take cD 1,2 turn 0 to denoise + cD1.fill(0) + cD2.fill(0) + for i in range(1, len(coeffs) - 2): + coeffs[i] = pywt.threshold(coeffs[i], threshold) + # get signal that before wavelet + rdata = pywt.waverec(coeffs=coeffs, wavelet='db5') + return rdata + + +# get ECG data,date type and denoise +# this function without return +# use append take return data to pass data +def getDataSet(number, X_data, Y_data): + ecgClassSet = ['N', 'A', 'V', 'L', 'R'] + print('get' + number + ' ECG data') + record = wfdb.rdrecord(MITBITECGDATAPATH + number, channel_names=['MLII']) + data = record.p_signal.flatten() + # use def denoise + rdata = denoise(date=data) + + # get type of ECG data + annotation = wfdb.rdann(MITBITECGDATAPATH + number, 'atr') + Rlocation = annotation.sample # annotation.sample:get R + Rclass = annotation.symbol + + # delete stable date near R + start = 10 + end = 5 + i = start + j = len(annotation.symbol) - end + + # get NAVLR type data + while i < j: + try: + lable = ecgClassSet.index(Rclass[i]) + x_train = rdata[Rlocation[i] - 99:Rlocation[i] + 201] + X_data.append(x_train) + Y_data.append(lable) + i += 1 + except ValueError: + i += 1 + return + + +# RATIO=The ratio of the training set to the test set,usually is 0.3 +def loadData(ratio, random_seed): + numberSet = ['100', '101', '103', '105', '106', '107', '108', '109', '111', '112', '113', '114', '115', + '116', '117', '119', '121', '122', '123', '124', '200', '201', '202', '203', '205', '208', + '210', '212', '213', '214', '215', '217', '219', '220', '221', '222', '223', '228', '230', + '231', '232', '233', '234'] + dataSet = [] + labelSet = [] + for n in numberSet: + getDataSet(n, dataSet, labelSet) + + # dataSet = np.array(dataSet).reshape(-1, 300) + # labelSet = np.array(labelSet).reshape(-1, 1) + + # reshape the data and split the dataset + dataSet = np.array(dataSet).reshape(-1, 300) + lableSet = np.array(labelSet).reshape(-1) + X_train, X_test, y_train, y_test = train_test_split(dataSet, lableSet, test_size=ratio, random_state=random_seed) + # print(X_train, X_test, y_train, y_test) + return X_train, X_test, y_train, y_test + + # train_ds = np.hstack((dataSet, labelSet)) + # np.random.shuffle(train_ds) + # + # X = train_ds[:, :300].reshape(-1, 300, 1) + # Y = train_ds[:, 300] + # # cut test and train data from ECG data + # shuffle_index = np.random.permutation(len(X)) + # test_length = int(RATIO * len(shuffle_index)) + # test_index = shuffle_index[:test_length] + # train_index = shuffle_index[test_index:] + # X_test, Y_test = X[test_index:], Y[test_index] + # X_train, Y_train = X[train_index], Y[train_index] + # return X_train, Y_test, X_test, Y_train + + +# confusion matrix +def plot_heat_map(y_test, y_pred): + con_mat = confusion_matrix(y_test, y_pred) + # normalize + # con_mat_norm = con_mat.astype('float') / con_mat.sum(axis=1)[:, np.newaxis] + # con_mat_norm = np.around(con_mat_norm, decimals=2) + # os.remove(PICTUREPATH+'confusion_matrix.png') + # plot + plt.figure(figsize=(8, 8)) + seaborn.heatmap(con_mat, annot=True, fmt='.20g', cmap='Blues') + plt.ylim(0, 5) + plt.xlabel('Predicted labels') + plt.ylabel('True labels') + plt.title('Confusion Matrix') + plt.savefig(PICTUREPATH + 'confusion_matrix.png') + plt.show() + + +def plot_history_tf(history): + # os.remove(PICTUREPATH+'accuracy.png') + # os.remove(PICTUREPATH+'loss.png') + + plt.figure(figsize=(8, 8)) + plt.plot(history.history['accuracy']) + plt.plot(history.history['val_accuracy']) + plt.title('Model Accuracy') + plt.ylabel('Accuracy') + plt.xlabel('Epoch') + plt.legend(['Train', 'Test'], loc='upper left') + plt.savefig(PICTUREPATH + 'accuracy.png') + plt.show() + + plt.figure(figsize=(8, 8)) + plt.plot(history.history['loss']) + plt.plot(history.history['val_loss']) + plt.title('Model Loss') + plt.ylabel('Loss') + plt.xlabel('Epoch') + plt.legend(['Train', 'Test'], loc='upper left') + plt.savefig(PICTUREPATH + 'loss.png') + plt.show() + + +def plot_history_torch(history): + plt.figure(figsize=(8, 8)) + plt.plot(history['train_acc']) + plt.plot(history['test_acc']) + plt.title('Model Accuracy') + plt.ylabel('Accuracy') + plt.xlabel('Epoch') + plt.legend(['Train', 'Test'], loc='upper left') + plt.savefig(PICTUREPATH + 'accuracy.png') + plt.show() + + plt.figure(figsize=(8, 8)) + plt.plot(history['train_loss']) + plt.plot(history['test_loss']) + plt.title('Model Loss') + plt.ylabel('Loss') + plt.xlabel('Epoch') + plt.legend(['Train', 'Test'], loc='upper left') + plt.savefig(PICTUREPATH + 'loss.png') + plt.show()