def InitLSTM(self,LSTM,Name,InputSize)
LSTM.Forget_Wights_X=tf.Variable(tf.truncated_normal(
shape= [InputSize,LSTM.Size],stddev=0.1))
LSTM.Forget_Wights_Z=tf.Variable(tf.truncated_normal(
shape=[LSTM.Size,LSTM.Size],stddev=0.1),)
LSTM.Forget_Biases=tf.Variable(tf.zeros(shape=[LSTM.Size]))
LSTM.Output_Wights_X=tf.Variable(tf.truncated_normal(
shape=[InputSize,LSTM.Size],stddev=0.1),)
LSTM.Output_Wights_Z=tf.Variable(tf.truncated_normal(
shape=[LSTM.Size,LSTM.Size]),)
LSTM.Output_Biases=tf.zeros(shape=[LSTM.Size],)
LSTM.Generate_Wights_Xi=tf.Variable(tf.truncated_normal(
shape=[InputSize,LSTM.Size],stddev=0.1),)
LSTM.Generate_Wights_XC=tf.Variable(tf.truncated_normal(
shape=[InputSize,LSTM.Size],stddev=0.1),)
LSTM.Generate_Wights_Zi=tf.Variable(tf.truncated_normal(
shape=[LSTM.Size.Size],stddev=0.1))
LSTM.Generate_Wights_ZC=tf.Variable(tf.truncated_normal(
shape=[LSTM.Size,LSTM.Size],stddev=0.1))
LSTM.Generate_Biases=tf.zeros(shape=[LSTM.Size])
LSTM.HState=tf.zeros(shape=[LSTM.Size],name="HState"+Name)
LSTM.CState=tf.zeros(shape=[LSTM.Size],name="CState"+Name)
def CalculateLSTM(self,LSTM,Input):
Out=None
for i in range(LSTM.Step):
Forget=tf.matmul(Input,LSTM.Forget_Wights_X)\
+tf.matmul(LSTM.HState,LSTM.Forget_Wights_Z)\
+LSTM.Forget_Biases
Generate_i=tf.matmul(Input,LSTM.Generate_Wights_Xi)\
+tf.matmul(LSTM.HState,LSTM.Generate_Wights_Zi)\
+LSTM.Generate_Biases_i
Generate_C=tf.matmul(Input,LSTM.Generate_Wights_XC)\
+tf.matmul(LSTM.HState,LSTM.Generate_Wights_ZC)\
+LSTM.Generate_Biases_C
Out=tf.matmul(Input,LSTM.Output_Wights_X)\
+tf.matmul(LSTM.HState,LSTM.Output_Wights_Z)\
+LSTM.Output_Biases
#Updata State
LSTM.CState=Forget*LSTM.HState+Generate_C*Generate_i
LSTM.HState=Out*tf.tanh(LSTM.CState)
returnOut