美文网首页
LSTM Custom

LSTM Custom

作者: Easize | 来源:发表于2017-10-21 22:45 被阅读0次

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

相关文章

  • LSTM Custom

    def InitLSTM(self,LSTM,Name,InputSize) LSTM.Forget_Wight...

  • pytorch1.0 搭建LSTM网络

    torch.nn包下实现了LSTM函数,实现LSTM层。多个LSTMcell组合起来是LSTM。 LSTM自动实现...

  • keras lstm 杂记

    1、例子 情感分析 情感分析(苏剑林) lstm多曲线预测 lstm多曲线预测(原文) 2、lstm参数 lstm...

  • 详解 LSTM

    今天的内容有: LSTM 思路 LSTM 的前向计算 LSTM 的反向传播 关于调参 LSTM 长短时记忆网络(L...

  • keras lstm return sequence参数理解

    使用keras构建多层lstm网络时,除了最后一层lstm,中间过程的lstm中的return sequence参...

  • LSTM

    Chris Olah's LSTM postEdwin Chen's LSTM postAndrej Karpat...

  • lstm理解

    本文是自己对于lstm的理解的总结,但是最好的文章帮助理解lstm一定是这篇Understanding LSTM ...

  • Tensorflow神经网络之LSTM

    LSTM 简介 公式 LSTM LSTM作为门控循环神经网络因此我们从门控单元切入理解。主要包括: 输入门:It ...

  • LSTM原理、源码、Demo及习题

    全面整理LSTM相关原理,源码,以及开发demo,设计习题。如转载请注明转载出处。 LSTM 框架 lstm 由3...

  • 双向 LSTM

    本文结构: 为什么用双向 LSTM 什么是双向 LSTM 例子 为什么用双向 LSTM? 单向的 RNN,是根据前...

网友评论

      本文标题:LSTM Custom

      本文链接:https://www.haomeiwen.com/subject/guvwuxtx.html