may be last version

By completing the thesis, we have corrected the deficiencies and fixed some bugs.
This commit is contained in:
weiyuqing committed 2023-04-18 18:43:14 +08:00
1 parent a13e1ace47
commit af187d92e9
49 files changed
+129 -7

No files matched your search

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 31 KiB

@@ -6,7 +6,7 @@ import pywt
import wfdb import wfdb
import tensorflow as tf import tensorflow as tf
from tensorflow import keras from tensorflow import keras
from utils_two_of_PoolCNN import loadData, plot_history_tf, plot_heat_map from utils_four_of_PoolCNN import loadData, plot_history_tf, plot_heat_map
#from ECG_read_weiyuqing_without_wfdb import ECGDATAPATH #from ECG_read_weiyuqing_without_wfdb import ECGDATAPATH
#PATH of this test #PATH of this test
@@ -6,7 +6,7 @@ import pywt
import wfdb import wfdb
import tensorflow as tf import tensorflow as tf
from tensorflow import keras from tensorflow import keras
from utils_two_of_PoolCNN import loadData, plot_history_tf, plot_heat_map from utils_one_of_PoolCNN import loadData, plot_history_tf, plot_heat_map
#from ECG_read_weiyuqing_without_wfdb import ECGDATAPATH #from ECG_read_weiyuqing_without_wfdb import ECGDATAPATH
#PATH of this test #PATH of this test
@@ -6,7 +6,7 @@ import pywt
import wfdb import wfdb
import tensorflow as tf import tensorflow as tf
from tensorflow import keras from tensorflow import keras
from utils_two_of_PoolCNN import loadData, plot_history_tf, plot_heat_map from utils_three_of_PoolCNN import loadData, plot_history_tf, plot_heat_map
#from ECG_read_weiyuqing_without_wfdb import ECGDATAPATH #from ECG_read_weiyuqing_without_wfdb import ECGDATAPATH
#PATH of this test #PATH of this test
Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

@@ -31,11 +31,11 @@ def CNN_model_level_one():
tf.keras.layers.InputLayer(input_shape=(300,)), tf.keras.layers.InputLayer(input_shape=(300,)),
tf.keras.layers.Reshape(target_shape=(300, 1)), tf.keras.layers.Reshape(target_shape=(300, 1)),
tf.keras.layers.Conv1D(filters=3, kernel_size=3, strides=2, padding='same', activation='relu'), tf.keras.layers.Conv1D(filters=71, kernel_size=3, strides=2, padding='same', activation='relu'),
tf.keras.layers.MaxPool1D(pool_size=1, strides=2, padding='same'), tf.keras.layers.MaxPool1D(pool_size=1, strides=2, padding='same'),
tf.keras.layers.Conv1D(filters=3, kernel_size=3, strides=2, padding='same', activation='relu'), tf.keras.layers.Conv1D(filters=71, kernel_size=3, strides=2, padding='same', activation='relu'),
tf.keras.layers.MaxPool1D(pool_size=1, strides=2, padding='same'), tf.keras.layers.MaxPool1D(pool_size=1, strides=2, padding='same'),
tf.keras.layers.Conv1D(filters=3, kernel_size=3, strides=2, padding='same', activation='relu'), tf.keras.layers.Conv1D(filters=71, kernel_size=3, strides=2, padding='same', activation='relu'),
tf.keras.layers.MaxPool1D(pool_size=1, strides=2, padding='same'), tf.keras.layers.MaxPool1D(pool_size=1, strides=2, padding='same'),
tf.keras.layers.Flatten(), tf.keras.layers.Flatten(),
-1
View File
@@ -33,7 +33,6 @@ def denoise(date):
coeffs[i] = pywt.threshold(coeffs[i], threshold) coeffs[i] = pywt.threshold(coeffs[i], threshold)
# get signal that before wavelet # get signal that before wavelet
rdata = pywt.waverec(coeffs=coeffs, wavelet='db5') rdata = pywt.waverec(coeffs=coeffs, wavelet='db5')
return rdata
# get ECG data,date type and denoise # get ECG data,date type and denoise
+44
View File
@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 11 20:41:57 2018
@author: brucelau
"""
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-10,10)
y_sigmoid = 1/(1+np.exp(-x))
y_tanh = (np.exp(x)-np.exp(-x))/(np.exp(x)+np.exp(-x))
fig = plt.figure()
# plot sigmoid
ax = fig.add_subplot(221)
ax.plot(x,y_sigmoid)
ax.grid()
ax.set_title('(a) Sigmoid')
# plot tanh
ax = fig.add_subplot(222)
ax.plot(x,y_tanh)
ax.grid()
ax.set_title('(b) Tanh')
# plot relu
ax = fig.add_subplot(223)
y_relu = np.array([0*item if item<0 else item for item in x ])
ax.plot(x,y_relu)
ax.grid()
ax.set_title('(c) ReLu')
#plot leaky relu
ax = fig.add_subplot(224)
y_relu = np.array([0.2*item if item<0 else item for item in x ])
ax.plot(x,y_relu)
ax.grid()
ax.set_title('(d) Leaky ReLu')
plt.tight_layout()
plt.show()
+29
View File
@@ -0,0 +1,29 @@
import pywt
import matplotlib.pyplot as plt
# 生成DB5小波
wavelet = pywt.Wavelet('db5')
# 获取尺度函数和小波函数
phi, psi, x = wavelet.wavefun(level=5)
# 绘制尺度函数和小波函数
plt.figure()
plt.subplot(2, 1, 1)
plt.plot(x, phi)
plt.title('DB5 Scaling Function (Phi)')
plt.subplot(2, 1, 2)
plt.plot(x, psi)
plt.title('DB5 Wavelet Function (Psi)')
plt.tight_layout()
plt.show()
h0=wavelet.dec_lo
h1=wavelet.dec_hi
g0=wavelet.rec_lo
g1=wavelet.rec_hi
print('h0:', h0)
print('h1:', h1)
print('g0:', g0)
print('g1:', g1)
+36
View File
@@ -0,0 +1,36 @@
import numpy as np
import keras
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten
from keras.layers import Conv2D, MaxPooling2D
from keras.optimizers import SGD
# 生成虚拟数据
x_train = np.random.random((100, 100, 100, 3))
y_train = keras.utils.to_categorical(np.random.randint(10, size=(100, 1)), num_classes=10)
x_test = np.random.random((20, 100, 100, 3))
y_test = keras.utils.to_categorical(np.random.randint(10, size=(20, 1)), num_classes=10)
model = Sequential()
# 输入: 3 通道 100x100 像素图像 -> (100, 100, 3) 张量。
# 使用 32 个大小为 3x3 的卷积滤波器。
model.add(Conv2D(32, (3, 3), activation='relu', input_shape=(100, 100, 3)))
model.add(Conv2D(32, (3, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Conv2D(64, (3, 3), activation='relu'))
model.add(Conv2D(64, (3, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(256, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(10, activation='softmax'))
sgd = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)
model.compile(loss='categorical_crossentropy', optimizer=sgd)
model.fit(x_train, y_train, batch_size=32, epochs=10)
score = model.evaluate(x_test, y_test, batch_size=32)
+14
View File
@@ -0,0 +1,14 @@
import numpy as np
import matplotlib.pyplot as plt
def softmax(x):
return np.exp(x) / np.sum(np.exp(x))
x = np.arange(-10, 10, 0.1)
y = softmax(x)
plt.plot(x, y)
plt.title('Softmax Function')
plt.xlabel('Input')
plt.ylabel('Output')
plt.show()