码迷,mamicode.com
首页 > 其他好文 > 详细

深度学习Keras框架笔记之TimeDistributedDense类

时间:2018-03-17 17:56:13      阅读:2490      评论:0      收藏:0      [点我收藏+]

标签:输入   基于   shape   模型   元素   highlight   input   com   ted   

    深度学习Keras框架笔记之TimeDistributedDense类使用方法笔记

    例:         

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)  
    

      

深度学习Keras框架笔记之TimeDistributedDense类

标签:输入   基于   shape   模型   元素   highlight   input   com   ted   

原文地址:https://www.cnblogs.com/68xi/p/8590759.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!