yusuketomoto/chainer-fast-neuralstyle

ValueError: test argument is not supported anymore. Use chainer.using_config

wangkepermit opened this issue · 5 comments

Hi! My Dear.
two question for you,Please!
# 1:
[root@localhost chainer-fast-neuralstyle]# python generate.py c1.jpg --model models/seurat.model --out o.jpg
Traceback (most recent call last):
File "generate.py", line 45, in
y = model(x)
File "/root/chainer-fast-neuralstyle/net.py", line 55, in call
h = self.b1(F.elu(self.c1(x)), test=test)
File "/usr/lib/python2.7/site-packages/chainer/links/normalization/batch_normalization.py", line 117, in call
kwargs, test='test argument is not supported anymore. '
File "/usr/lib/python2.7/site-packages/chainer/utils/argument.py", line 4, in check_unexpected_kwargs
raise ValueError(message)
ValueError: test argument is not supported anymore. Use chainer.using_config
# 2.
[root@localhost chainer-fast-neuralstyle]# python generate.py c1.jpg --model models/vgg16.model --out o.jpg
Traceback (most recent call last):
File "generate.py", line 30, in
serializers.load_npz(args.model, model)
File "/usr/lib/python2.7/site-packages/chainer/serializers/npz.py", line 134, in load_npz
d.load(obj)
File "/usr/lib/python2.7/site-packages/chainer/serializer.py", line 82, in load
obj.serialize(self)
File "/usr/lib/python2.7/site-packages/chainer/link.py", line 792, in serialize
d[name].serialize(serializer[name])
File "/usr/lib/python2.7/site-packages/chainer/link.py", line 792, in serialize
d[name].serialize(serializer[name])
File "/usr/lib/python2.7/site-packages/chainer/link.py", line 548, in serialize
data = serializer(name, param.data)
File "/usr/lib/python2.7/site-packages/chainer/serializers/npz.py", line 106, in call
dataset = self.npz[key]
File "/usr/lib64/python2.7/site-packages/numpy/lib/npyio.py", line 237, in getitem
raise KeyError("%s is not a file in the archive" % key)
KeyError: 'r4/c2/W is not a file in the archive'

Last: How adjust CPU and GPU number?

For the first one, even I am facing the same issue?
is there a dependency issue?

Was also getting an error about "test=" in generate.py
Solved that by removing all "test" entries in generate.py

Also noticed train.py was giving me errors,
fixed it by removing all "volatile" lines in train.py

Not sure what these were used for but its working without them

The first problem was caused by the version update of chainer.
The offical explains are:

In Chainer v2, the concept of training mode is added. It is represented by a thread-local flag chainer.config.train, which is a part of the unified configuration. When chainer.config.train is True, functions of Chainer run in the training mode, and otherwise they run in the test mode. For example, BatchNormalization and dropout() behave differently in each mode.

In Chainer v1, such a behavior was configured by the train or test argument of each function. This train/test argument has been removed in Chainer v2. If your code is using the train or test argument, you have to update it. In most cases, what you have to do is just removing the train / test argument from any function calls.

Also you can find examples here:
https://docs.chainer.org/en/stable/upgrade.html#global-configurations

Is there a solution to this? Downgrade chainer or upgrade the code?

Hi, you can take a look at my docker image where I have it running: https://github.com/jtomori/style_transfer_docker

I also forked the repo and did small adjustments, you should be able to get it running without docker too: https://github.com/jtomori/chainer-fast-neuralstyle/tree/resize-conv