Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tv_weight = 0 => attempt to index upvalue 'module' (a nil value) #205

Open
alehander92 opened this issue Apr 12, 2016 · 6 comments
Open

Comments

@alehander92
Copy link

Hey, I am trying to run the example on Ubuntu, only CPU with

th neural_style.lua -style_image examples/inputs/picasso_selfport1907.jpg -content_image examples/inputs/brad_pitt.jpg -output_image profile.png -model_file models/nin_imagenet_conv.caffemodel -proto_file models/train_val.prototxt -num_iterations 1000 -seed 123 -content_layers relu0,relu3,relu7,relu12 -style_layers relu0,relu3,relu7,relu12 -content_weight 10 -style_weight 1000 -image_size 256 -optimizer adam -gpu -1 -tv_weight 0

I am using -tv_weight because otherwise it's producing only gray images with loss 0 and I saw 149

I am getting

Running optimization with ADAM  
/usr/bin/lua5.1: /usr/local/share/lua/5.1/nn/Container.lua:67: 
In 1 module of nn.Sequential:
/usr/local/share/lua/5.1/nn/Container.lua:59: attempt to index upvalue 'module' (a nil value)
stack traceback:
    /usr/local/share/lua/5.1/nn/Container.lua:59: in function </usr/local/share/lua/5.1/nn/Container.lua:58>
    [C]: in function 'xpcall'
    /usr/local/share/lua/5.1/nn/Container.lua:58: in function 'rethrowErrors'
    /usr/local/share/lua/5.1/nn/Sequential.lua:58: in function 'updateGradInput'
    neural_style.lua:320: in function 'opfunc'
    /usr/local/share/lua/5.1/optim/adam.lua:33: in function 'adam'
    neural_style.lua:343: in function 'main'
    neural_style.lua:500: in main chunk
    [C]: in function 'dofile'
    /usr/local/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
    [C]: ?

WARNING: If you see a stack trace below, it doesn't point to the place where this error occured. Please use only the one above.
stack traceback:
    [C]: in function 'error'
    /usr/local/share/lua/5.1/nn/Container.lua:67: in function 'rethrowErrors'
    /usr/local/share/lua/5.1/nn/Sequential.lua:58: in function 'updateGradInput'
    neural_style.lua:320: in function 'opfunc'
    /usr/local/share/lua/5.1/optim/adam.lua:33: in function 'adam'
    neural_style.lua:343: in function 'main'
    neural_style.lua:500: in main chunk
    [C]: in function 'dofile'
    /usr/local/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
    [C]: ?
@htoyryla
Copy link

This may not help in your case, but I would not use adam with nin-imagenet as my first choice. Nin-imagenet appears more difficult to get to converge and l-bfgs is definitely better in that.

@alehander92
Copy link
Author

I am downloading the VGG 19 layers one now, I just wondered if that's a sign that something else on my system is not ok(or a bug)

@htoyryla
Copy link

You can use l-bfgs with nin-imagenet, just leave out -optimizer adam.

But there is probably something wrong in your setup. Running the same I get the following. Are you sure you have the correct model? Md5sum gives 8fbacb8dd696607876386e34ff68a84a models/nin_imagenet_conv.caffemodel

th neural_style.lua -style_image examples/inputs/picasso_selfport1907.jpg -content_image examples/inputs/brad_pitt.jpg -output_image profile.png -model_file models/nin_imagenet_conv.caffemodel -proto_file models/train_val.prototxt -num_iterations 1000 -seed 123 -content_layers relu0,relu3,relu7,relu12 -style_layers relu0,relu3,relu7,relu12 -content_weight 10 -style_weight 1000 -image_size 256 -optimizer adam -gpu -1 -tv_weight 0

Successfully loaded models/nin_imagenet_conv.caffemodel
MODULE data UNDEFINED
warning: module 'data [type 5]' not found
conv1: 96 3 11 11
cccp1: 96 96 1 1
cccp2: 96 96 1 1
conv2: 256 96 5 5
cccp3: 256 256 1 1
cccp4: 256 256 1 1
conv3: 384 256 3 3
cccp5: 384 384 1 1
cccp6: 384 384 1 1
conv4-1024: 1024 384 3 3
cccp7-1024: 1024 1024 1 1
cccp8-1024: 1000 1024 1 1
Setting up content layer    2   :   relu0   
Setting up style layer      2   :   relu0   
Setting up content layer    9   :   relu3   
Setting up style layer      9   :   relu3   
Setting up content layer    16  :   relu7   
Setting up style layer      16  :   relu7   
Setting up content layer    28  :   relu12  
Setting up style layer      28  :   relu12  
Running optimization with ADAM  
Iteration 50 / 1000 
  Content 1 loss: 116326.865234 
  Content 2 loss: 364734.375000 
  Content 3 loss: 197101.347656 
  Content 4 loss: 1452.863007   
  Style 1 loss: 139646.621704   
  Style 2 loss: 172335.678101   
  Style 3 loss: 99164.207458    
  Style 4 loss: 3.526320    
  Total loss: 1090765.484481    

@alehander92
Copy link
Author

I guess so, but the error persists.
-tv_weight 0 => error
(-tv_weight default) =>
adam => loss 0, gray image
l-bfgs => actually nothing happens, exits immediately aft

Running optimization with L-BFGS    
<optim.lbfgs>   creating recyclable direction/step/history buffers  
<optim.lbfgs>   function value changing less than tolX  ```

@htoyryla
Copy link

Nin-imagenet-conv may be a bit difficult to get started with some inputs. Usually it helps to try again a couple of times (with random seed). Leave out the -seed parameter and try again a few times.

On the other hand, on my computer it starts ok with your parameters including -seed 123 so something else is now different in your setup.

Check the model file with md5sum and compare with mine in my previous comment.

@3DTOPO
Copy link

3DTOPO commented Apr 12, 2016

Install my pull request #97 and it will fix "function value changing less than tolX" error. Note that when I submitted it it was free of conflicts but does not appear to be the case anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants