【问题标题】:GRUCells in TensorFlow: TypeError got multiple values for keyword argument 'num_units'TensorFlow 中的 GRUCells:TypeError 为关键字参数“num_units”获取了多个值
【发布时间】:2017-08-23 16:00:33
【问题描述】:

所以我有这个非常简单的玩具代码:

import tensorflow as tf

x = tf.placeholder(tf.int32, [None, 10])

def new_network(x):
    return  tf.nn.rnn_cell.GRUCell(x, num_units=100)

pred = new_network(x)

无论我做什么,我都会收到以下错误

TypeError: __init__() got multiple values for keyword argument 'num_units'

我使用的是 TensorFlow 1.3.0 版本。

这和this pulled issue有关吗?

【问题讨论】:

    标签: python tensorflow


    【解决方案1】:

    tf.nn.rnn_cell.GRUCell 使用num_units 和激活等进行初始化,但不使用输入。使用__call__ 方法时会传递输入

    GRUCell.__init__(
        num_units,
        activation=None,
        reuse=None,
        kernel_initializer=None,
        bias_initializer=None
    )
    
    state = tf.placeholder(tf.int32, [None, state_size])
    def new_network(x):
        gru_cell = tf.nn.rnn_cell.GRUCell(num_units=100)
        y = gru_cell(x, state)
    pred = new_network(x)
    

    【讨论】:

    • 我真傻,有时我会迷失在 TF 的文档和版本控制中。谢谢!
    猜你喜欢
    • 2013-08-04
    • 2016-06-24
    • 2015-05-18
    • 1970-01-01
    • 2013-03-09
    • 2016-04-25
    • 2012-11-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多