深度學習Keras框架筆記之TimeDistributedDense類

    深度學習Keras框架筆記之TimeDistributedDense類使用方法筆記python

    例:         網絡

keras.layers.core.TimeDistributedDense(output_dim,init='glorot_uniform', activation='linear', weights=None  
W_regularizer=None, b_regularizer=None, activity_regularizer=None, W_constraint=None, b_constraint=None,  
input_dim=None, input_length=None)   

 這是一個基於時間維度的全鏈接層。主要就是用來構建RNN(遞歸神經網絡)的,可是在構建RNN時須要設置return_sequences=True。框架

       inputshape: 3維 tensor(nb_samples, timesteps,input_dim)函數

       參數:學習

  •        output_dim: int >= 0,輸出結果的維度
  •        init : 初始化權值的函數名稱或Theano function。可使用Keras內置的,也能夠傳遞本身編寫的Theano function。若是不給weights傳遞參數時,則該參數必須指明。
  •        activation : 激活函數名稱或者Theano function。可使用Keras內置的,也能夠是傳遞本身編寫的Theano function。若是不明確指定,那麼將沒有激活函數會被應用。
  •        weights :用於初始化權值的numpy arrays組成的list。這個List至少有1個元素,其shape爲(input_dim, output_dim)。(若是指定init了,那麼weights能夠賦值None)
  •        W_regularizer:權值的規則化項,必須傳入一個WeightRegularizer的實例(好比L1或L2規則化項)。
  •        b_regularizer:偏置值的規則化項,必須傳入一個WeightRegularizer的實例(好比L1或L2規則化項)。
  •        activity_regularizer:網絡輸出的規則化項,必須傳入一個ActivityRegularizer的實例。
  •        W_constraint:權值約束,必須傳入一個constraints的實例。
  •        b_constraint:偏置約束,必須傳入一個constraints的實例。
  •        input_dim:輸入數據的維度。這個參數會在模型的第一層中用到。
  •        input_length:Length of input sequences, whenit is constant. This argument is required if you are going to connect Flattenthen Dense layers upstream (without it, the shape of the dense outputs cannotbe computed).
  • 例如:
  • # input shape: (nb_samples, timesteps,10)  
    model.add(LSTM(5, return_sequences=True, input_dim=10)) # output shape: (nb_samples, timesteps, 5)  
    model.add(TimeDistributedDense(15)) # output shape:(nb_samples, timesteps, 15)
相關文章
相關標籤/搜索