accel-brain / accel-brain-code

The purpose of this repository is to make prototypes as case study in the context of proof of concept(PoC) and research and development(R&D) that I have written in my website. The main research topics are Auto-Encoders in relation to the representation learning, the statistical machine learning for energy-based models, adversarial generation networks(GANs), Deep Reinforcement Learning such as Deep Q-Networks, semi-supervised learning, and neural network language model for natural language processing.
https://accel-brain.co.jp
GNU General Public License v2.0
310 stars 92 forks source link

TypeError: collect_params() takes 1 positional argument but 2 were given #24

Closed nikidziuba closed 3 years ago

nikidziuba commented 3 years ago

When setting up GANImageGenerator (using tutorial on PyPI) I get following error:

Python\Python37\lib\site-packages\accelbrainbase\observabledata\_mxnet\convolutional_neural_networks.py", line 211, in collect_params
    params_dict = super().collect_params(select)
TypeError: collect_params() takes 1 positional argument but 2 were given

Here's my code:

from pygan.gan_image_generator import GANImageGenerator
from logging import getLogger, StreamHandler, NullHandler, DEBUG, ERROR

logger = getLogger("accelbrainbase")
handler = StreamHandler()
handler.setLevel(DEBUG)
logger.setLevel(DEBUG)
logger.addHandler(handler)

gan_image_generator = GANImageGenerator(
    # `list` of path to your directories.
    dir_list=[
        "Source", 
    ],
    # `int` of image width.
    width=1024,
    # `int` of image height.
    height=1024,
    # `int` of image channel.
    channel=1,
    # `int` of batch size.
    batch_size=40,
    # `float` of learning rate.
    learning_rate=1e-06,
)

I'm using python 3.7

accel-brain commented 3 years ago

I wasn't able to replicate that bug.

The code calls GANImageGenerator. Do you know why does the error log start by mentioning the contents of convolutional_neural_networks.py ?

nikidziuba commented 3 years ago

Here's the whole log:

Warning (from warnings module):
  File "C:\Users\xxxx\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\selectors.py", line 14
    from collections import namedtuple, Mapping
DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working

Warning (from warnings module):
  File "C:\Users\xxxx\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\_collections.py", line 2
    from collections import Mapping, MutableMapping
DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
Traceback (most recent call last):
  File "D:\GAN\GAN.py", line 24, in <module>
    learning_rate=1e-06,
  File "C:\Users\xxxx\AppData\Local\Programs\Python\Python37\lib\site-packages\pygan\gan_image_generator.py", line 193, in __init__
    scale=1.0,
  File "C:\Users\xxxx\AppData\Local\Programs\Python\Python37\lib\site-packages\accelbrainbase\observabledata\_mxnet\convolutional_neural_networks.py", line 171, in __init__
    self.collect_params().initialize(self.initializer, force_reinit=True, ctx=ctx)
  File "C:\Users\xxxx\AppData\Local\Programs\Python\Python37\lib\site-packages\accelbrainbase\observabledata\_mxnet\convolutional_neural_networks.py", line 211, in collect_params
    params_dict = super().collect_params(select)
TypeError: collect_params() takes 1 positional argument but 2 were given

I think it's beacause the collect_params() is in convolutional_neural_networks.py. If it helps I can post its code too

Thank you for your help btw

accel-brain commented 3 years ago

Please tell me the version of the mxnet library installed in your environment. Also, please tell me just in case. Are you transfer the trained parameters to the model?

nikidziuba commented 3 years ago

I'm using mxnet 1.7.0 but i think i found the issue. Mxnet uses numpy and requests, which are used by tensorflow and tensorboard. They are using diffrent versions of it, and that creates incomability

Here are errors after reinstalling mxnet:

tensorflow 2.4.1 has requirement numpy~=1.19.2, but you'll have numpy 1.16.6 which is incompatible.
tensorboard 2.4.1 has requirement requests<3,>=2.21.0, but you'll have requests 2.18.4 which is incompatible.
accel-brain commented 3 years ago

Please switch the environment of pyenv or conda and reinstall them individually.

nikidziuba commented 3 years ago

I tried conda and it didn't work. I'm closing this ticket as you can't replicate it so it's problem with my computer. If I figure something out i will write it here. Thanks for your help and time