代码语法问题

来源:9-19 构建解码器(8)

激进的小学生

2019-05-23

    def cell_input_fn(inputs,attention):
        if not self.use_residual:
            return array_ops.concat([inputs,attention],-1)

        att_projection=layers.Dense(self.hidden_units,
                                    dtype=tf.float32,
                                    use_bias=False,
                                    name='attention_cell_input_fn')
        return att_projection(array_ops.concat[inputs,attention],-1)

    cell=AttentionWrapper(
        cell=cell,
        attention_mechanism=self.attention_mechanism,
        attention_layer_size=self.hidden_units,
        alignment_history=alignment_history,
        cell_input_fn=cell_input_fn,
        name='Attention_Wrapper'
    )

这段代码中att_projection是layers.Dense生成的一个对象吗,返回att_projection(array_ops.concat[inputs,attention],-1)是什么意思,对象还能再传参吗。
cell中传入内部函数cell_input_fn,那么函数的参数inputs,attention在哪里传进去。

写回答

1回答

Mr_Ricky

2019-06-09

layers.Dense你可以理解为是一个全连接层的对象,cell_input_fn是指前向传播的参数,你可以看下这里面的调用。

0
1
激进的小学生
对象可以接收参数吗
2019-06-24
共1条回复

NLP实践TensorFlow打造聊天机器人

解析自然语言处理( NLP )常用技术,从0搭建聊天机器人应用并部署上线,可用于毕设。

673 学习 · 281 问题

查看课程