BP 神经网络——处理数据
import tensorflow as tf
import numpy as np
import pandas as pd
from numpy import *
import matplotlib.pyplot as plt
#load battery data
weights = tf.Variable(tf.truncated_normal([5,1],stddev=0.01,name='weights1'))
biases = tf.Variable(0.1,name='biases1')
xs=tf.placeholder(tf.float32,[None,5])
ys=tf.placeholder(tf.float32,[None,1])
layer1=tf.matmul(xs,weights)+biases
loss=tf.square(layer1-ys)
train_step=tf.train.GradientDescentOptimizer(0.0001).minimize(loss)
saver = tf.train.Saver()
save_file = 'Data/my_test/DST_soc50/para_iden1.ckpt'
with tf.Session() as sess:
saver.restore(sess, save_file)
for j in range(135):
points = pd.read_csv("Data/mixed/mixed_modify/mixed%d_modify.csv" % (j + 1),
encoding='GBK')
V = points['V']
A = points['A']
U = V[:-2]
U1 = V[1:-1]
U2 = V[2:]
a = A[2:]
a1 = A[1:-1]
a2 = A[:-2]
X1 = []
Y1 = []
for u1, u2, i, i1, i2 in zip(U1, U, a, a1, a2):
c = [u1, u2, -i, -i1, -i2]
X1.append(c)
for v in U2:
Y1.append(v)
length = np.shape(X1)[0]
q = 0
评论6