代码
import pywt
import matplotlib.pyplot as plt
import numpy as np
import preprocess
path = r'data/0HP'
num_classes = 10 # 样本类别
length = 784 # 样本长度
number = 300 # 每类样本的数量
normal = True # 是否标准化
rate = [0.6, 0.2, 0.2] # 测试集验证集划分比例
x_train, y_train, x_valid, y_valid, x_test, y_test =preprocess.prepro(
d_path=path,
length=length,
number=number,
normal=normal,
rate=rate,
enc=False,enc_step=28)
for i in range(0, len(x_train)):
N = 784
fs = 12000
t = np.linspace(0, 784 / fs, N, endpoint=False)
wavename = 'cmor3-3'
totalscal = 256
fc = pywt.central_frequency(wavename)
cparam = 2 * fc * totalscal
scales = cparam / np.arange(totalscal, 1, -1)
[cwtmatr, frequencies] = pywt.cwt(x_train[i], scales, wavename, 1.0 / fs)
plt.contourf(t, frequencies, abs(cwtmatr))
plt.axis('off')
plt.gcf().set_size_inches(784 / 100, 784 / 100)
plt.gca().xaxis.set_major_locator(plt.NullLocator())
plt.gca().yaxis.set_major_locator(plt.NullLocator())
plt.subplots_adjust(top=1, bottom=0, right=1, left=0, hspace=0, wspace=0)
plt.margins(0, 0)
x = r'/cwt_picture/train/' + str(i) + '-' + str(y_train[i]) + '.jpg'
plt.savefig(x)
D:\Anaconda3\envs\tensorflow\python.exe E:\Bearing-fault-Diagnosis-based-on-deep-learning-main\cwt\sign_cwt.py
Traceback (most recent call last):
File "E:\Bearing-fault-Diagnosis-based-on-deep-learning-main\cwt\sign_cwt.py", line 23, in <module>
x_train, y_train, x_valid, y_valid, x_test, y_test =preprocess.prepro(
TypeError: prepro() got an unexpected keyword argument 'enc'
Process finished with exit code 1
我想要达到的结果
怎么解决这个问题,能让他正常运行