def plot(): ''' 画图 :return: ''' dir = MCU_dir # 数据集保存路径 model = My_CNN(40, 17, 1000, dir) # 初始化模型 hist_path = dir + 'Adam_' history = model.load_data(hist_path, 'history') plt.figure() plt.plot(history['acc']) hist_path = dir + 'SGD_' history = model.load_data(hist_path, 'history') plt.plot(history['acc']) hist_path = dir + 'Adadelta_' history = model.load_data(hist_path, 'history') plt.plot(history['acc']) hist_path = dir + 'Adagrad_' history = model.load_data(hist_path, 'history') plt.plot(history['acc']) plt.legend(['Adam', 'SGD', 'Adadelta', 'Adagrad']) plt.show()
def write(): # 将二进制文件写为csv格式,方便之后用MATLAB画图 # MFPT dir = MFPT_dir # 数据集保存路径 model = My_CNN(40, 16, 1000, dir) # 初始化模型 # LBCNN+Adam hist_path = dir + 'Adam_' history = model.load_data(hist_path, 'history') filename = dir + 'Adam.csv' csv_trans(history, filename) # LBCNN+SGD hist_path = dir + 'SGD_' history = model.load_data(hist_path, 'history') filename = dir + 'SGD.csv' csv_trans(history, filename) # LBCNN+Adagrad hist_path = dir + 'Adagrad_' history = model.load_data(hist_path, 'history') filename = dir + 'Adagrad.csv' csv_trans(history, filename) # LBCNN+Adadelta hist_path = dir + 'Adadelta_' history = model.load_data(hist_path, 'history') filename = dir + 'Adadelta.csv' csv_trans(history, filename) #LBCNN hist_path = dir + 'LBCNN_' history = model.load_data(hist_path, 'history') filename = dir + 'LBCNN.csv' csv_trans(history, filename) # Lenet hist_path = dir + 'Lenet_' history = model.load_data(hist_path, 'history') filename = dir + 'Lenet.csv' csv_trans(history, filename) # race hist_path = dir + 'RLenet_' history = model.load_data(hist_path, 'history') filename = dir + 'RLenet.csv' csv_trans(history, filename) hist_path = dir + 'RLBCNN_' history = model.load_data(hist_path, 'history') filename = dir + 'RLBCNN.csv' csv_trans(history, filename) # MCU dir = MCU_dir # 数据集保存路径 model = My_CNN(40, 17, 1000, dir) # 初始化模型 # LBCNN+Adam hist_path = dir + 'Adam_' history = model.load_data(hist_path, 'history') filename = dir + 'Adam.csv' csv_trans(history, filename) # LBCNN+SGD hist_path = dir + 'SGD_' history = model.load_data(hist_path, 'history') filename = dir + 'SGD.csv' csv_trans(history, filename) # LBCNN+Adagrad hist_path = dir + 'Adagrad_' history = model.load_data(hist_path, 'history') filename = dir + 'Adagrad.csv' csv_trans(history, filename) # LBCNN+Adadelta hist_path = dir + 'Adadelta_' history = model.load_data(hist_path, 'history') filename = dir + 'Adadelta.csv' csv_trans(history, filename) # LBCNN hist_path = dir + 'LBCNN_' history = model.load_data(hist_path, 'history') filename = dir + 'LBCNN.csv' csv_trans(history, filename) # Lenet hist_path = dir + 'Lenet_' history = model.load_data(hist_path, 'history') filename = dir + 'Lenet.csv' csv_trans(history, filename) # race hist_path = dir + 'RLenet_' history = model.load_data(hist_path, 'history') filename = dir + 'RLenet.csv' csv_trans(history, filename) hist_path = dir + 'RLBCNN_' history = model.load_data(hist_path, 'history') filename = dir + 'RLBCNN.csv' csv_trans(history, filename)