解决TypeError: __init__() takes from 1 to 3 positional arguments but 6 were given

简介: 解决TypeError: __init__() takes from 1 to 3 positional arguments but 6 were given

2022-01-12 22:20:24.272950: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
Traceback (most recent call last):
  File "E:/Code/PyCharm/深度学习/图像分类/NIN/train.py", line 27, in <module>
    history = model.NIN(10)
  File "E:\Code\PyCharm\深度学习\图像分类\NIN\model.py", line 26, in __init__
    kernel_size=1)
  File "D:\Anaconda\lib\site-packages\tensorflow\python\training\tracking\base.py", line 530, in _method_wrapper
    result = method(self, *args, **kwargs)
TypeError: __init__() takes from 1 to 3 positional arguments but 6 were given

问题原因:

我在使用Sequential模块搭建网络时,中间掺杂不同的层,但是我们有用列表进行封装,所以导致参数不对应

解决方案:

使用列表进行封装使之成为一个参数

self.mlpconv1 = Sequential([
            Conv2D(filters=6,
                   kernel_size=1),
            ReLU(),
            Conv2D(filters=6,
                   kernel_size=1),
            ReLU(),
            Conv2D(filters=6,
                   kernel_size=1)]
        )


目录
相关文章
|
4月前
|
SQL 数据库连接 数据库
【Python】已完美解决:executemany() takes exactly 2 positional arguments (3 given)
【Python】已完美解决:executemany() takes exactly 2 positional arguments (3 given)
66 6
|
4月前
|
Python
【Python】已解决:TypeError: write._Log() takes 0 positional arguments but 1 was given
【Python】已解决:TypeError: write._Log() takes 0 positional arguments but 1 was given
65 0
|
4月前
|
开发者 Python
【Python】已解决:SyntaxError: positional argument follows keyword argument
【Python】已解决:SyntaxError: positional argument follows keyword argument
121 0
|
4月前
|
机器学习/深度学习 Python
【Python】已解决TypeError: init() got an unexpected keyword argument ‘threshold’
【Python】已解决TypeError: init() got an unexpected keyword argument ‘threshold’
96 0
|
4月前
|
Python
【Python】已解决:TypeError: *init*() missing 1 required positional argument: ‘scheme’
【Python】已解决:TypeError: *init*() missing 1 required positional argument: ‘scheme’
243 0
|
6月前
|
Python
完美解决丨TypeError: fun() takes 2 positional arguments but 3 were given
完美解决丨TypeError: fun() takes 2 positional arguments but 3 were given
TypeError: custom() got an unexpected keyword argument ‘path‘
TypeError: custom() got an unexpected keyword argument ‘path‘
146 0
|
计算机视觉
成功解决TypeError: __init__() got an unexpected keyword argument 'n_iterations'
成功解决TypeError: __init__() got an unexpected keyword argument 'n_iterations'
成功解决TypeError: __init__() got an unexpected keyword argument 'serialized_options'
成功解决TypeError: __init__() got an unexpected keyword argument 'serialized_options'