• 大小: 10KB
    文件类型: .py
    金币: 1
    下载: 0 次
    发布日期: 2021-05-24
  • 语言: Python
  • 标签: 神经网络  

资源简介

有284个训练样本,273个测试样本,通过对数据的处理后进入基于LSTM的多层循环神经网络进行训练,测试样本测试准确率可达70+

资源截图

代码片段和文件信息


“““


      ┏┛ ┻━━━━━┛ ┻┓
      ┃       ┃
      ┃   ━   ┃
      ┃ ┳┛   ┗┳ ┃
      ┃       ┃
      ┃   ┻   ┃
      ┃       ┃
      ┗━┓   ┏━━━┛
        ┃   ┃   神兽保佑
        ┃   ┃   代码无BUG!
        ┃   ┗━━━━━━━━━┓
        ┃           ┣┓
        ┃             ┏┛
        ┗━┓ ┓ ┏━━━┳ ┓ ┏━┛
          ┃ ┫ ┫   ┃ ┫ ┫
          ┗━┻━┛   ┗━┻━┛

“““
import tensorflow as tf
import  numpy as np
import  scipy.io
import time

data =scipy.io.loadmat(‘G2MM06_NormalDataSet_train.mat‘)
data1=scipy.io.loadmat(‘G2MM06_NormalDataSet_test.mat‘)

print(data1[‘DataSet‘][0][0][0][0][5])
pi=data1[‘DataSet‘][0][0][0][0][5]
print(pi[0][0]pi[0][1])

log_dir=‘/tmp/tensorflow/logs/12‘
“““
X_train[0]=np.array(X_train[0])
X_train[0]=np.array(X_train[0]) 
print(X_train[0][0][1]np.shape(X_train[0]))
“““

lst=[]
for m in range(284):
     X_train = data[‘DataSet‘][m][0][0][0][2]
     X_train=X_train.T
     pi = data[‘DataSet‘][m][0][0][0][5]
     
     for k in range(6):
       for i in range(57):
         for j in range(1+i):
             lst.append(X_train[k][i][j])

       lst.append(pi[0][0])
       lst.append(pi[0][1])
         

X_trainNew1=np.array(lst)
X_trainNew1=X_trainNew1.reshape([-11655])

X_trainMu1=data[‘DataSet‘][0][0][0][0][1]
for i in range(283):
    X_trainMu1=np.hstack((X_trainMu1data[‘DataSet‘][i+1][0][0][0][1]))
X_trainMu1=X_trainMu1.T

X_trainNew1 = np.hstack((X_trainNew1X_trainMu1))
print(“训练集“)
print(X_trainNew1np.shape(X_trainNew1))



lst3=[]
for m in range(284):
     X_train = data[‘DataSet‘][m][0][0][0][4]
     X_train=X_train.T

     for k in range(6):
       for i in range(57):
         for j in range(1+i):
             lst3.append(X_train[k][i][j])
X_trainNew2=np.array(lst3)
X_trainNew2=X_trainNew2.reshape([-11653])

X_trainMu2=data[‘DataSet‘][0][0][0][0][3]
for i in range(283):
    X_trainMu2=np.hstack((X_trainMu2data[‘DataSet‘][i+1][0][0][0][3]))
X_trainMu2=X_trainMu2.T

X_trainNew2 = np.hstack((X_trainNew2X_trainMu2))
print(“训练集“)
print(X_trainNew2np.shape(X_trainNew2))




X_trainNew3=np.hstack((X_trainNew1X_trainNew2))
print(np.shape(X_trainNew3))





lst1=[]
for m in range(273):
     X_test = data1[‘DataSet‘][m][0][0][0][2]
     X_test=X_test.T
     pi = data1[‘DataSet‘][m][0][0][0][5]
     for k in range(6):
       for i in range(57):
         for j in range(1+i):
             lst1.append(X_test[k][i][j])
       lst1.append(pi[0][0])
       lst1.append(pi[0][1])


X_testNew1=np.array(lst1)
X_testNew1=X_testNew1.reshape([-11655])

X_testMu1=data1[‘DataSet‘][0][0][0][0][1]
for i in range(272):
    X_testMu1=np.hstack((X_testMu1data1[‘DataSet‘][i+1][0][0][0][1]))
X_testMu1=X_testMu1.T

X_testNew1 = np.hstack((X_testNew1X_testMu1))

print(“测试集“)
print(X_testNew1np.shape(X_testNew1))

lst4=[]
for m in range(273):
     X_test = data1[‘DataSet‘][m][0][0][0][4]
     X_test=X_test.T
     for k in range(6):
       for i in range(57):
         for j in range(1+i):
             lst4.append(X_test[k][i][j])

X_testNew2=np.array(lst4)
X_testNew2

评论

共有 条评论