简体   繁体   English

TypeError:__init__() 为参数“轴”获取了多个值

[英]TypeError: __init__() got multiple values for argument 'axes'

I want to use attention mechanism with the code bellow:我想在下面的代码中使用注意机制:

attention = Dot([decoder_outputs, encoder_outputs], axes=[2, 1])
attention = Activation('softmax')(attention)

context = Dot([attention, encoder_outputs], axes=[2,1])
decoder_combined_context = concatenate([context, decoder_outputs])

But i have this error message and i don't know how to fix it但我有这个错误信息,我不知道如何解决它

Traceback (most recent call last):

    attention = Dot([decoder_outputs, encoder_outputs], axes=[2, 1])

TypeError: __init__() got multiple values for argument 'axes'

I'm using keras version 2.3.1 with tensorflow version 2.1.0我正在使用 keras 版本 2.3.1 和 tensorflow 版本 2.1.0

The first argument to Dot is called axes : Dot第一个参数称为axes

tf.keras.layers.Dot(axes, normalize=False, **kwargs)

So you need to decide what value you want to pass for axes : either [decoder_outputs, encoder_outputs] or [2, 1] .因此,您需要决定要axes传递什么值: [decoder_outputs, encoder_outputs][2, 1]

You are not calling the layer correctly, it should be like this:您没有正确调用图层,它应该是这样的:

attention = Dot(axes=[2, 1])([decoder_outputs, encoder_outputs])

Your second call to Dot has the same issue, it follows the same pattern您对Dot的第二次调用有同样的问题,它遵循相同的模式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TypeError:__init __()为参数'n_splits'获取了多个值 - TypeError: __init__() got multiple values for argument 'n_splits' TypeError:__init __()为参数'fieldnames'获得了多个值 - TypeError: __init__() got multiple values for argument 'fieldnames' 类型错误:__init__() 为参数“strides”获得了多个值 - TypeError: __init__() got multiple values for argument 'strides' Python TypeError:__ init __()为参数'master'获取了多个值 - Python TypeError: __init__() got multiple values for argument 'master' TypeError:__init __()为关键字参数“ choices”获得了多个值 - TypeError: __init__() got multiple values for keyword argument 'choices' TypeError:“ __ init __()为关键字参数'name'获得了多个值” - TypeError: “__init__() got multiple values for keyword argument 'name'” TypeError: __init__() 为参数 'center' 获得了多个值 - TypeError: __init__() got multiple values for argument 'center' TypeError:__ init __()得到关键字参数'customer'的多个值 - TypeError: __init__() got multiple values for keyword argument 'customer' 类型错误:__init__() 为参数“index”获得了多个值 - TypeError: __init__() got multiple values for argument 'index' SQLAlchemy TypeError:__init __()为参数'name'获得了多个值 - SQLAlchemy TypeError: __init__() got multiple values for argument 'name'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM