Code Monkey home page Code Monkey logo

dcgan.caffe's Introduction

dcgan.caffe: A pure caffe-python implementation of DC-GAN

As far as I know, there is no light-weight implementation of DCGAN based on caffe.

Inspired by DeePSiM implementation, a few lines of python code can train the dcgan model quickly without any hack in caffe core lib (Dosovitskiy has already done this. However, I think the code could be merged back to master branch).

Dependency

You will need to compile the deepsim-caffe-branch. And make sure your PYTHONPATH point to it.

The deepsim-caffe only support cudnn-4.0. If disable the cudnn engine and replace some convolution layers with the master branch, a latest cudnn and cuda will work fine.

Training

For face generator, please prepare celebA dataset as the link said. Then make a train list file and put it in the data.prototxt.

Just typing

python train.py

Train file list

Each line has two columns seperated by space. The second column indicates the label of the corresponding image. Actually the label could be all zeros, since the training only need the images themselves to be the targets.

The file should look like

/data/Repo/dcgan.torch/celebA/img_align_celeba/000001.jpg 0
/data/Repo/dcgan.torch/celebA/img_align_celeba/000002.jpg 0
/data/Repo/dcgan.torch/celebA/img_align_celeba/000003.jpg 0
/data/Repo/dcgan.torch/celebA/img_align_celeba/000004.jpg 0
/data/Repo/dcgan.torch/celebA/img_align_celeba/000005.jpg 0
/data/Repo/dcgan.torch/celebA/img_align_celeba/000006.jpg 0
/data/Repo/dcgan.torch/celebA/img_align_celeba/000007.jpg 0
/data/Repo/dcgan.torch/celebA/img_align_celeba/000008.jpg 0
/data/Repo/dcgan.torch/celebA/img_align_celeba/000009.jpg 0
/data/Repo/dcgan.torch/celebA/img_align_celeba/000010.jpg 0
/data/Repo/dcgan.torch/celebA/img_align_celeba/000011.jpg 0
/data/Repo/dcgan.torch/celebA/img_align_celeba/000012.jpg 0
/data/Repo/dcgan.torch/celebA/img_align_celeba/000013.jpg 0
...

Trouble shooting

Visualization

To view the model result by

python generate.py generator.prototxt snapshots_test/4000/generator.caffemodel

The visualizations of the models at iteration 3000 and 4000 are as following:

3000

4000

dcgan.caffe's People

Contributors

samson-wang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dcgan.caffe's Issues

Can't run train.py without correct label information, plz help!

Hi, @samson-wang

Thanks for your work on replicating DCGAN in CAFFE!

And I'd like run it on my machine.

Unfortunately, when I run python train.py, after successfully build deepsim branch of CAFFE and deploy the CelebA dataset as you mentioned in the README file, I encountered the following problem. It seems that the source of ImageDataLayer is not correct, which need label information. But now, I have only image files without labels.

So could u please kindly provide me your celebA.txt? Thanks very much!

/opt/share1/Engine/caffe-fr-chairs/python/caffe/pycaffe.py:13: RuntimeWarning: to-Python converter for boost::shared_ptr<caffe::Net<float> > already registered; second conversion method ignored.
  from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
/opt/share1/Engine/caffe-fr-chairs/python/caffe/pycaffe.py:13: RuntimeWarning: to-Python converter for boost::shared_ptr<caffe::Blob<float> > already registered; second conversion method ignored.
  from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
/opt/share1/Engine/caffe-fr-chairs/python/caffe/pycaffe.py:13: RuntimeWarning: to-Python converter for boost::shared_ptr<caffe::Solver<float> > already registered; second conversion method ignored.
  from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
WARNING: Logging before InitGoogleLogging() is written to STDERR
I1121 12:57:28.830848   571 upgrade_proto.cpp:1044] Attempting to upgrade input file specified using deprecated 'solver_type' field (enum)': solver_generator.prototxt
I1121 12:57:28.830896   571 upgrade_proto.cpp:1051] Successfully upgraded file specified using deprecated 'solver_type' field (enum) to 'type' field (string).
W1121 12:57:28.830902   571 upgrade_proto.cpp:1053] Note that future Caffe releases will only support 'type' field (string) for a solver's type.
I1121 12:57:28.830953   571 solver.cpp:48] Initializing solver from parameters: 
base_lr: 0.0002
display: 0
max_iter: 15000
lr_policy: "multistep"
gamma: 0.5
momentum: 0.5
weight_decay: 0.0004
solver_mode: GPU
device_id: 0
net: "generator.prototxt"
stepvalue: 6000
stepvalue: 10000
stepvalue: 140000
stepvalue: 180000
stepvalue: 220000
momentum2: 0.999
type: "Adam"
I1121 12:57:28.830971   571 solver.cpp:91] Creating training net from net file: generator.prototxt
I1121 12:57:28.831181   571 upgrade_proto.cpp:66] Attempting to upgrade input file specified using deprecated input fields: generator.prototxt
I1121 12:57:28.831193   571 upgrade_proto.cpp:69] Successfully upgraded file specified using deprecated input fields.
W1121 12:57:28.831195   571 upgrade_proto.cpp:71] Note that future Caffe releases will only support input layers and not input fields.
I1121 12:57:28.831231   571 net.cpp:313] The NetState phase (0) differed from the phase (1) specified by a rule in layer deconv5_BN
I1121 12:57:28.831239   571 net.cpp:313] The NetState phase (0) differed from the phase (1) specified by a rule in layer deconv5_1_BN
I1121 12:57:28.831243   571 net.cpp:313] The NetState phase (0) differed from the phase (1) specified by a rule in layer deconv4_BN
I1121 12:57:28.831248   571 net.cpp:313] The NetState phase (0) differed from the phase (1) specified by a rule in layer deconv4_1_BN
I1121 12:57:28.831357   571 net.cpp:49] Initializing net from parameters: 
force_backward: true
state {
  phase: TRAIN
}
layer {
  name: "input"
  type: "Input"
  top: "feat"
  input_param {
    shape {
      dim: 64
      dim: 100
    }
  }
}
layer {
  name: "reshape"
  type: "Reshape"
  bottom: "feat"
  top: "reshape_defc5"
  reshape_param {
    shape {
      dim: 64
      dim: 100
      dim: 1
      dim: 1
    }
  }
}
layer {
  name: "deconv5"
  type: "Deconvolution"
  bottom: "reshape_defc5"
  top: "deconv5"
  param {
    lr_mult: 1
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  convolution_param {
    num_output: 512
    pad: 0
    kernel_size: 4
    stride: 1
    weight_filler {
      type: "gaussian"
      std: 0.02
    }
    bias_filler {
      type: "constant"
    }
  }
}
layer {
  name: "deconv5_BN"
  type: "BatchNorm"
  bottom: "deconv5"
  top: "deconv5_BN"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  include {
    phase: TRAIN
  }
  batch_norm_param {
    use_global_stats: false
    moving_average_fraction: 0.95
  }
}
layer {
  name: "relu_deconv5"
  type: "ReLU"
  bottom: "deconv5_BN"
  top: "deconv5_BN"
}
layer {
  name: "conv5_1"
  type: "Deconvolution"
  bottom: "deconv5_BN"
  top: "conv5_1"
  param {
    lr_mult: 1
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  convolution_param {
    num_output: 256
    pad: 1
    kernel_size: 4
    stride: 2
    weight_filler {
      type: "gaussian"
      std: 0.02
    }
    bias_filler {
      type: "constant"
    }
  }
}
layer {
  name: "deconv5_1_BN"
  type: "BatchNorm"
  bottom: "conv5_1"
  top: "deconv5_1_BN"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  include {
    phase: TRAIN
  }
  batch_norm_param {
    use_global_stats: false
    moving_average_fraction: 0.95
  }
}
layer {
  name: "relu_conv5_1"
  type: "ReLU"
  bottom: "deconv5_1_BN"
  top: "deconv5_1_BN"
}
layer {
  name: "deconv4"
  type: "Deconvolution"
  bottom: "deconv5_1_BN"
  top: "deconv4"
  param {
    lr_mult: 1
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  convolution_param {
    num_output: 128
    pad: 1
    kernel_size: 4
    stride: 2
    weight_filler {
      type: "gaussian"
      std: 0.02
    }
    bias_filler {
      type: "constant"
    }
  }
}
layer {
  name: "deconv4_BN"
  type: "BatchNorm"
  bottom: "deconv4"
  top: "deconv4_BN"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  include {
    phase: TRAIN
  }
  batch_norm_param {
    use_global_stats: false
    moving_average_fraction: 0.95
  }
}
layer {
  name: "relu_deconv4"
  type: "ReLU"
  bottom: "deconv4_BN"
  top: "deconv4_BN"
}
layer {
  name: "conv4_1"
  type: "Deconvolution"
  bottom: "deconv4_BN"
  top: "conv4_1"
  param {
    lr_mult: 1
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  convolution_param {
    num_output: 64
    pad: 1
    kernel_size: 4
    stride: 2
    weight_filler {
      type: "gaussian"
      std: 0.02
    }
    bias_filler {
      type: "constant"
    }
  }
}
layer {
  name: "deconv4_1_BN"
  type: "BatchNorm"
  bottom: "conv4_1"
  top: "deconv4_1_BN"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  include {
    phase: TRAIN
  }
  batch_norm_param {
    use_global_stats: false
    moving_average_fraction: 0.95
  }
}
layer {
  name: "relu_conv4_1"
  type: "ReLU"
  bottom: "deconv4_1_BN"
  top: "deconv4_1_BN"
}
layer {
  name: "generated"
  type: "Deconvolution"
  bottom: "deconv4_1_BN"
  top: "generated"
  param {
    lr_mult: 1
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  convolution_param {
    num_output: 3
    pad: 1
    kernel_size: 4
    stride: 2
    weight_filler {
      type: "gaussian"
      std: 0.02
    }
    bias_filler {
      type: "constant"
    }
  }
}
I1121 12:57:28.831419   571 layer_factory.hpp:77] Creating layer input
I1121 12:57:28.831435   571 net.cpp:91] Creating Layer input
I1121 12:57:28.831439   571 net.cpp:399] input -> feat
I1121 12:57:28.852150   571 net.cpp:141] Setting up input
I1121 12:57:28.852257   571 net.cpp:148] Top shape: 64 100 (6400)
I1121 12:57:28.852283   571 net.cpp:156] Memory required for data: 25600
I1121 12:57:28.852310   571 layer_factory.hpp:77] Creating layer reshape
I1121 12:57:28.852331   571 net.cpp:91] Creating Layer reshape
I1121 12:57:28.852339   571 net.cpp:425] reshape <- feat
I1121 12:57:28.852346   571 net.cpp:399] reshape -> reshape_defc5
I1121 12:57:28.852388   571 net.cpp:141] Setting up reshape
I1121 12:57:28.852397   571 net.cpp:148] Top shape: 64 100 1 1 (6400)
I1121 12:57:28.852401   571 net.cpp:156] Memory required for data: 51200
I1121 12:57:28.852404   571 layer_factory.hpp:77] Creating layer deconv5
I1121 12:57:28.852416   571 net.cpp:91] Creating Layer deconv5
I1121 12:57:28.852421   571 net.cpp:425] deconv5 <- reshape_defc5
I1121 12:57:28.852427   571 net.cpp:399] deconv5 -> deconv5
I1121 12:57:28.866683   571 net.cpp:141] Setting up deconv5
I1121 12:57:28.866726   571 net.cpp:148] Top shape: 64 512 4 4 (524288)
I1121 12:57:28.866729   571 net.cpp:156] Memory required for data: 2148352
I1121 12:57:28.866753   571 layer_factory.hpp:77] Creating layer deconv5_BN
I1121 12:57:28.866773   571 net.cpp:91] Creating Layer deconv5_BN
I1121 12:57:28.866778   571 net.cpp:425] deconv5_BN <- deconv5
I1121 12:57:28.866796   571 net.cpp:399] deconv5_BN -> deconv5_BN
I1121 12:57:28.866976   571 net.cpp:141] Setting up deconv5_BN
I1121 12:57:28.866984   571 net.cpp:148] Top shape: 64 512 4 4 (524288)
I1121 12:57:28.866986   571 net.cpp:156] Memory required for data: 4245504
I1121 12:57:28.866997   571 layer_factory.hpp:77] Creating layer relu_deconv5
I1121 12:57:28.867007   571 net.cpp:91] Creating Layer relu_deconv5
I1121 12:57:28.867010   571 net.cpp:425] relu_deconv5 <- deconv5_BN
I1121 12:57:28.867014   571 net.cpp:386] relu_deconv5 -> deconv5_BN (in-place)
I1121 12:57:28.867020   571 net.cpp:141] Setting up relu_deconv5
I1121 12:57:28.867024   571 net.cpp:148] Top shape: 64 512 4 4 (524288)
I1121 12:57:28.867027   571 net.cpp:156] Memory required for data: 6342656
I1121 12:57:28.867029   571 layer_factory.hpp:77] Creating layer conv5_1
I1121 12:57:28.867039   571 net.cpp:91] Creating Layer conv5_1
I1121 12:57:28.867044   571 net.cpp:425] conv5_1 <- deconv5_BN
I1121 12:57:28.867049   571 net.cpp:399] conv5_1 -> conv5_1
I1121 12:57:28.903168   571 net.cpp:141] Setting up conv5_1
I1121 12:57:28.903208   571 net.cpp:148] Top shape: 64 256 8 8 (1048576)
I1121 12:57:28.903214   571 net.cpp:156] Memory required for data: 10536960
I1121 12:57:28.903241   571 layer_factory.hpp:77] Creating layer deconv5_1_BN
I1121 12:57:28.903261   571 net.cpp:91] Creating Layer deconv5_1_BN
I1121 12:57:28.903270   571 net.cpp:425] deconv5_1_BN <- conv5_1
I1121 12:57:28.903285   571 net.cpp:399] deconv5_1_BN -> deconv5_1_BN
I1121 12:57:28.903520   571 net.cpp:141] Setting up deconv5_1_BN
I1121 12:57:28.903532   571 net.cpp:148] Top shape: 64 256 8 8 (1048576)
I1121 12:57:28.903534   571 net.cpp:156] Memory required for data: 14731264
I1121 12:57:28.903548   571 layer_factory.hpp:77] Creating layer relu_conv5_1
I1121 12:57:28.903560   571 net.cpp:91] Creating Layer relu_conv5_1
I1121 12:57:28.903564   571 net.cpp:425] relu_conv5_1 <- deconv5_1_BN
I1121 12:57:28.903570   571 net.cpp:386] relu_conv5_1 -> deconv5_1_BN (in-place)
I1121 12:57:28.903576   571 net.cpp:141] Setting up relu_conv5_1
I1121 12:57:28.903583   571 net.cpp:148] Top shape: 64 256 8 8 (1048576)
I1121 12:57:28.903585   571 net.cpp:156] Memory required for data: 18925568
I1121 12:57:28.903589   571 layer_factory.hpp:77] Creating layer deconv4
I1121 12:57:28.903602   571 net.cpp:91] Creating Layer deconv4
I1121 12:57:28.903606   571 net.cpp:425] deconv4 <- deconv5_1_BN
I1121 12:57:28.903614   571 net.cpp:399] deconv4 -> deconv4
I1121 12:57:28.915402   571 net.cpp:141] Setting up deconv4
I1121 12:57:28.915426   571 net.cpp:148] Top shape: 64 128 16 16 (2097152)
I1121 12:57:28.915431   571 net.cpp:156] Memory required for data: 27314176
I1121 12:57:28.915442   571 layer_factory.hpp:77] Creating layer deconv4_BN
I1121 12:57:28.915455   571 net.cpp:91] Creating Layer deconv4_BN
I1121 12:57:28.915467   571 net.cpp:425] deconv4_BN <- deconv4
I1121 12:57:28.915477   571 net.cpp:399] deconv4_BN -> deconv4_BN
I1121 12:57:28.915743   571 net.cpp:141] Setting up deconv4_BN
I1121 12:57:28.915755   571 net.cpp:148] Top shape: 64 128 16 16 (2097152)
I1121 12:57:28.915760   571 net.cpp:156] Memory required for data: 35702784
I1121 12:57:28.915771   571 layer_factory.hpp:77] Creating layer relu_deconv4
I1121 12:57:28.915778   571 net.cpp:91] Creating Layer relu_deconv4
I1121 12:57:28.915784   571 net.cpp:425] relu_deconv4 <- deconv4_BN
I1121 12:57:28.915791   571 net.cpp:386] relu_deconv4 -> deconv4_BN (in-place)
I1121 12:57:28.915799   571 net.cpp:141] Setting up relu_deconv4
I1121 12:57:28.915822   571 net.cpp:148] Top shape: 64 128 16 16 (2097152)
I1121 12:57:28.915827   571 net.cpp:156] Memory required for data: 44091392
I1121 12:57:28.915832   571 layer_factory.hpp:77] Creating layer conv4_1
I1121 12:57:28.915841   571 net.cpp:91] Creating Layer conv4_1
I1121 12:57:28.915846   571 net.cpp:425] conv4_1 <- deconv4_BN
I1121 12:57:28.915854   571 net.cpp:399] conv4_1 -> conv4_1
I1121 12:57:28.920480   571 net.cpp:141] Setting up conv4_1
I1121 12:57:28.920524   571 net.cpp:148] Top shape: 64 64 32 32 (4194304)
I1121 12:57:28.920532   571 net.cpp:156] Memory required for data: 60868608
I1121 12:57:28.920548   571 layer_factory.hpp:77] Creating layer deconv4_1_BN
I1121 12:57:28.920562   571 net.cpp:91] Creating Layer deconv4_1_BN
I1121 12:57:28.920569   571 net.cpp:425] deconv4_1_BN <- conv4_1
I1121 12:57:28.920578   571 net.cpp:399] deconv4_1_BN -> deconv4_1_BN
I1121 12:57:28.920861   571 net.cpp:141] Setting up deconv4_1_BN
I1121 12:57:28.920888   571 net.cpp:148] Top shape: 64 64 32 32 (4194304)
I1121 12:57:28.920897   571 net.cpp:156] Memory required for data: 77645824
I1121 12:57:28.920907   571 layer_factory.hpp:77] Creating layer relu_conv4_1
I1121 12:57:28.920914   571 net.cpp:91] Creating Layer relu_conv4_1
I1121 12:57:28.920922   571 net.cpp:425] relu_conv4_1 <- deconv4_1_BN
I1121 12:57:28.920928   571 net.cpp:386] relu_conv4_1 -> deconv4_1_BN (in-place)
I1121 12:57:28.920938   571 net.cpp:141] Setting up relu_conv4_1
I1121 12:57:28.920948   571 net.cpp:148] Top shape: 64 64 32 32 (4194304)
I1121 12:57:28.920953   571 net.cpp:156] Memory required for data: 94423040
I1121 12:57:28.920958   571 layer_factory.hpp:77] Creating layer generated
I1121 12:57:28.920966   571 net.cpp:91] Creating Layer generated
I1121 12:57:28.920971   571 net.cpp:425] generated <- deconv4_1_BN
I1121 12:57:28.920979   571 net.cpp:399] generated -> generated
I1121 12:57:28.925832   571 net.cpp:141] Setting up generated
I1121 12:57:28.925853   571 net.cpp:148] Top shape: 64 3 64 64 (786432)
I1121 12:57:28.925856   571 net.cpp:156] Memory required for data: 97568768
I1121 12:57:28.925868   571 net.cpp:219] generated does not need backward computation.
I1121 12:57:28.925875   571 net.cpp:219] relu_conv4_1 does not need backward computation.
I1121 12:57:28.925881   571 net.cpp:219] deconv4_1_BN does not need backward computation.
I1121 12:57:28.925886   571 net.cpp:219] conv4_1 does not need backward computation.
I1121 12:57:28.925892   571 net.cpp:219] relu_deconv4 does not need backward computation.
I1121 12:57:28.925896   571 net.cpp:219] deconv4_BN does not need backward computation.
I1121 12:57:28.925902   571 net.cpp:219] deconv4 does not need backward computation.
I1121 12:57:28.925907   571 net.cpp:219] relu_conv5_1 does not need backward computation.
I1121 12:57:28.925914   571 net.cpp:219] deconv5_1_BN does not need backward computation.
I1121 12:57:28.925918   571 net.cpp:219] conv5_1 does not need backward computation.
I1121 12:57:28.925925   571 net.cpp:219] relu_deconv5 does not need backward computation.
I1121 12:57:28.925928   571 net.cpp:219] deconv5_BN does not need backward computation.
I1121 12:57:28.925935   571 net.cpp:219] deconv5 does not need backward computation.
I1121 12:57:28.925940   571 net.cpp:219] reshape does not need backward computation.
I1121 12:57:28.925945   571 net.cpp:219] input does not need backward computation.
I1121 12:57:28.925951   571 net.cpp:261] This network produces output generated
I1121 12:57:28.925971   571 net.cpp:274] Network initialization done.
I1121 12:57:28.926055   571 solver.cpp:60] Solver scaffolding done.
I1121 12:57:28.927521   571 upgrade_proto.cpp:1044] Attempting to upgrade input file specified using deprecated 'solver_type' field (enum)': solver_discriminator.prototxt
I1121 12:57:28.927554   571 upgrade_proto.cpp:1051] Successfully upgraded file specified using deprecated 'solver_type' field (enum) to 'type' field (string).
W1121 12:57:28.927572   571 upgrade_proto.cpp:1053] Note that future Caffe releases will only support 'type' field (string) for a solver's type.
I1121 12:57:28.927633   571 solver.cpp:48] Initializing solver from parameters: 
base_lr: 0.0002
display: 0
max_iter: 15000
lr_policy: "multistep"
gamma: 0.5
momentum: 0.5
weight_decay: 0.0004
solver_mode: GPU
device_id: 0
net: "discriminator.prototxt"
stepvalue: 6000
stepvalue: 10000
stepvalue: 140000
stepvalue: 180000
stepvalue: 220000
momentum2: 0.999
type: "Adam"
I1121 12:57:28.927691   571 solver.cpp:91] Creating training net from net file: discriminator.prototxt
I1121 12:57:28.928021   571 upgrade_proto.cpp:66] Attempting to upgrade input file specified using deprecated input fields: discriminator.prototxt
I1121 12:57:28.928040   571 upgrade_proto.cpp:69] Successfully upgraded file specified using deprecated input fields.
W1121 12:57:28.928045   571 upgrade_proto.cpp:71] Note that future Caffe releases will only support input layers and not input fields.
I1121 12:57:28.928095   571 net.cpp:313] The NetState phase (0) differed from the phase (1) specified by a rule in layer Dconv2_BN
I1121 12:57:28.928105   571 net.cpp:313] The NetState phase (0) differed from the phase (1) specified by a rule in layer Dconv3_BN
I1121 12:57:28.928115   571 net.cpp:313] The NetState phase (0) differed from the phase (1) specified by a rule in layer Dconv4_BN
I1121 12:57:28.928336   571 net.cpp:49] Initializing net from parameters: 
force_backward: true
state {
  phase: TRAIN
}
layer {
  name: "input"
  type: "Input"
  top: "data"
  top: "label"
  input_param {
    shape {
      dim: 64
      dim: 3
      dim: 64
      dim: 64
    }
    shape {
      dim: 64
      dim: 1
    }
  }
}
layer {
  name: "Dconv1"
  type: "Convolution"
  bottom: "data"
  top: "Dconv1"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  convolution_param {
    num_output: 64
    pad: 1
    kernel_size: 4
    stride: 2
    weight_filler {
      type: "gaussian"
      std: 0.02
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
}
layer {
  name: "Drelu1"
  type: "ReLU"
  bottom: "Dconv1"
  top: "Dconv1"
  relu_param {
    negative_slope: 0.2
  }
}
layer {
  name: "Dconv2"
  type: "Convolution"
  bottom: "Dconv1"
  top: "Dconv2"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  convolution_param {
    num_output: 128
    pad: 1
    kernel_size: 4
    stride: 2
    weight_filler {
      type: "gaussian"
      std: 0.02
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
}
layer {
  name: "Dconv2_BN"
  type: "BatchNorm"
  bottom: "Dconv2"
  top: "Dconv2_BN"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  include {
    phase: TRAIN
  }
  batch_norm_param {
    use_global_stats: false
    moving_average_fraction: 0.95
  }
}
layer {
  name: "Drelu2"
  type: "ReLU"
  bottom: "Dconv2_BN"
  top: "Dconv2_BN"
  relu_param {
    negative_slope: 0.2
  }
}
layer {
  name: "Dconv3"
  type: "Convolution"
  bottom: "Dconv2_BN"
  top: "Dconv3"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  convolution_param {
    num_output: 256
    pad: 1
    kernel_size: 4
    stride: 2
    weight_filler {
      type: "gaussian"
      std: 0.02
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
}
layer {
  name: "Dconv3_BN"
  type: "BatchNorm"
  bottom: "Dconv3"
  top: "Dconv3_BN"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  include {
    phase: TRAIN
  }
  batch_norm_param {
    use_global_stats: false
    moving_average_fraction: 0.95
  }
}
layer {
  name: "Drelu3"
  type: "ReLU"
  bottom: "Dconv3_BN"
  top: "Dconv3_BN"
  relu_param {
    negative_slope: 0.2
  }
}
layer {
  name: "Dconv4"
  type: "Convolution"
  bottom: "Dconv3_BN"
  top: "Dconv4"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  convolution_param {
    num_output: 512
    pad: 1
    kernel_size: 4
    stride: 2
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
}
layer {
  name: "Dconv4_BN"
  type: "BatchNorm"
  bottom: "Dconv4"
  top: "Dconv4_BN"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  include {
    phase: TRAIN
  }
  batch_norm_param {
    use_global_stats: false
    moving_average_fraction: 0.95
  }
}
layer {
  name: "Drelu4"
  type: "ReLU"
  bottom: "Dconv4_BN"
  top: "Dconv4_BN"
  relu_param {
    negative_slope: 0.2
  }
}
layer {
  name: "Dconv5"
  type: "Convolution"
  bottom: "Dconv4_BN"
  top: "Dconv5"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  convolution_param {
    num_output: 512
    pad: 0
    kernel_size: 4
    stride: 1
    weight_filler {
      type: "gaussian"
      std: 0.02
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
}
layer {
  name: "Dfc7"
  type: "InnerProduct"
  bottom: "Dconv5"
  top: "Dfc7"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  inner_product_param {
    num_output: 1
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
}
layer {
  name: "discr_loss"
  type: "SigmoidCrossEntropyLoss"
  bottom: "Dfc7"
  bottom: "label"
  top: "discr_loss"
  loss_weight: 1
}
I1121 12:57:28.928416   571 layer_factory.hpp:77] Creating layer input
I1121 12:57:28.928426   571 net.cpp:91] Creating Layer input
I1121 12:57:28.928433   571 net.cpp:399] input -> data
I1121 12:57:28.928444   571 net.cpp:399] input -> label
I1121 12:57:28.928499   571 net.cpp:141] Setting up input
I1121 12:57:28.928508   571 net.cpp:148] Top shape: 64 3 64 64 (786432)
I1121 12:57:28.928514   571 net.cpp:148] Top shape: 64 1 (64)
I1121 12:57:28.928519   571 net.cpp:156] Memory required for data: 3145984
I1121 12:57:28.928524   571 layer_factory.hpp:77] Creating layer Dconv1
I1121 12:57:28.928536   571 net.cpp:91] Creating Layer Dconv1
I1121 12:57:28.928541   571 net.cpp:425] Dconv1 <- data
I1121 12:57:28.928550   571 net.cpp:399] Dconv1 -> Dconv1
I1121 12:57:28.928889   571 net.cpp:141] Setting up Dconv1
I1121 12:57:28.928900   571 net.cpp:148] Top shape: 64 64 32 32 (4194304)
I1121 12:57:28.928907   571 net.cpp:156] Memory required for data: 19923200
I1121 12:57:28.928920   571 layer_factory.hpp:77] Creating layer Drelu1
I1121 12:57:28.928930   571 net.cpp:91] Creating Layer Drelu1
I1121 12:57:28.928936   571 net.cpp:425] Drelu1 <- Dconv1
I1121 12:57:28.928944   571 net.cpp:386] Drelu1 -> Dconv1 (in-place)
I1121 12:57:28.928954   571 net.cpp:141] Setting up Drelu1
I1121 12:57:28.928977   571 net.cpp:148] Top shape: 64 64 32 32 (4194304)
I1121 12:57:28.928982   571 net.cpp:156] Memory required for data: 36700416
I1121 12:57:28.928987   571 layer_factory.hpp:77] Creating layer Dconv2
I1121 12:57:28.928997   571 net.cpp:91] Creating Layer Dconv2
I1121 12:57:28.929002   571 net.cpp:425] Dconv2 <- Dconv1
I1121 12:57:28.929010   571 net.cpp:399] Dconv2 -> Dconv2
I1121 12:57:28.931574   571 net.cpp:141] Setting up Dconv2
I1121 12:57:28.931588   571 net.cpp:148] Top shape: 64 128 16 16 (2097152)
I1121 12:57:28.931592   571 net.cpp:156] Memory required for data: 45089024
I1121 12:57:28.931603   571 layer_factory.hpp:77] Creating layer Dconv2_BN
I1121 12:57:28.931617   571 net.cpp:91] Creating Layer Dconv2_BN
I1121 12:57:28.931622   571 net.cpp:425] Dconv2_BN <- Dconv2
I1121 12:57:28.931632   571 net.cpp:399] Dconv2_BN -> Dconv2_BN
I1121 12:57:28.931888   571 net.cpp:141] Setting up Dconv2_BN
I1121 12:57:28.931900   571 net.cpp:148] Top shape: 64 128 16 16 (2097152)
I1121 12:57:28.931905   571 net.cpp:156] Memory required for data: 53477632
I1121 12:57:28.931917   571 layer_factory.hpp:77] Creating layer Drelu2
I1121 12:57:28.931927   571 net.cpp:91] Creating Layer Drelu2
I1121 12:57:28.931933   571 net.cpp:425] Drelu2 <- Dconv2_BN
I1121 12:57:28.931947   571 net.cpp:386] Drelu2 -> Dconv2_BN (in-place)
I1121 12:57:28.931957   571 net.cpp:141] Setting up Drelu2
I1121 12:57:28.931963   571 net.cpp:148] Top shape: 64 128 16 16 (2097152)
I1121 12:57:28.931969   571 net.cpp:156] Memory required for data: 61866240
I1121 12:57:28.931974   571 layer_factory.hpp:77] Creating layer Dconv3
I1121 12:57:28.931984   571 net.cpp:91] Creating Layer Dconv3
I1121 12:57:28.931990   571 net.cpp:425] Dconv3 <- Dconv2_BN
I1121 12:57:28.931999   571 net.cpp:399] Dconv3 -> Dconv3
I1121 12:57:28.943500   571 net.cpp:141] Setting up Dconv3
I1121 12:57:28.943578   571 net.cpp:148] Top shape: 64 256 8 8 (1048576)
I1121 12:57:28.943646   571 net.cpp:156] Memory required for data: 66060544
I1121 12:57:28.943696   571 layer_factory.hpp:77] Creating layer Dconv3_BN
I1121 12:57:28.943723   571 net.cpp:91] Creating Layer Dconv3_BN
I1121 12:57:28.943732   571 net.cpp:425] Dconv3_BN <- Dconv3
I1121 12:57:28.943743   571 net.cpp:399] Dconv3_BN -> Dconv3_BN
I1121 12:57:28.944108   571 net.cpp:141] Setting up Dconv3_BN
I1121 12:57:28.944118   571 net.cpp:148] Top shape: 64 256 8 8 (1048576)
I1121 12:57:28.944121   571 net.cpp:156] Memory required for data: 70254848
I1121 12:57:28.944133   571 layer_factory.hpp:77] Creating layer Drelu3
I1121 12:57:28.944145   571 net.cpp:91] Creating Layer Drelu3
I1121 12:57:28.944150   571 net.cpp:425] Drelu3 <- Dconv3_BN
I1121 12:57:28.944156   571 net.cpp:386] Drelu3 -> Dconv3_BN (in-place)
I1121 12:57:28.944164   571 net.cpp:141] Setting up Drelu3
I1121 12:57:28.944170   571 net.cpp:148] Top shape: 64 256 8 8 (1048576)
I1121 12:57:28.944175   571 net.cpp:156] Memory required for data: 74449152
I1121 12:57:28.944177   571 layer_factory.hpp:77] Creating layer Dconv4
I1121 12:57:28.944193   571 net.cpp:91] Creating Layer Dconv4
I1121 12:57:28.944197   571 net.cpp:425] Dconv4 <- Dconv3_BN
I1121 12:57:28.944206   571 net.cpp:399] Dconv4 -> Dconv4
I1121 12:57:28.988428   571 net.cpp:141] Setting up Dconv4
I1121 12:57:28.988487   571 net.cpp:148] Top shape: 64 512 4 4 (524288)
I1121 12:57:28.988502   571 net.cpp:156] Memory required for data: 76546304
I1121 12:57:28.988526   571 layer_factory.hpp:77] Creating layer Dconv4_BN
I1121 12:57:28.988559   571 net.cpp:91] Creating Layer Dconv4_BN
I1121 12:57:28.988569   571 net.cpp:425] Dconv4_BN <- Dconv4
I1121 12:57:28.988582   571 net.cpp:399] Dconv4_BN -> Dconv4_BN
I1121 12:57:28.988858   571 net.cpp:141] Setting up Dconv4_BN
I1121 12:57:28.988868   571 net.cpp:148] Top shape: 64 512 4 4 (524288)
I1121 12:57:28.988871   571 net.cpp:156] Memory required for data: 78643456
I1121 12:57:28.988885   571 layer_factory.hpp:77] Creating layer Drelu4
I1121 12:57:28.988903   571 net.cpp:91] Creating Layer Drelu4
I1121 12:57:28.988906   571 net.cpp:425] Drelu4 <- Dconv4_BN
I1121 12:57:28.988911   571 net.cpp:386] Drelu4 -> Dconv4_BN (in-place)
I1121 12:57:28.988919   571 net.cpp:141] Setting up Drelu4
I1121 12:57:28.988925   571 net.cpp:148] Top shape: 64 512 4 4 (524288)
I1121 12:57:28.988929   571 net.cpp:156] Memory required for data: 80740608
I1121 12:57:28.988930   571 layer_factory.hpp:77] Creating layer Dconv5
I1121 12:57:28.988943   571 net.cpp:91] Creating Layer Dconv5
I1121 12:57:28.988948   571 net.cpp:425] Dconv5 <- Dconv4_BN
I1121 12:57:28.988955   571 net.cpp:399] Dconv5 -> Dconv5
I1121 12:57:29.053995   571 net.cpp:141] Setting up Dconv5
I1121 12:57:29.054064   571 net.cpp:148] Top shape: 64 512 1 1 (32768)
I1121 12:57:29.054072   571 net.cpp:156] Memory required for data: 80871680
I1121 12:57:29.054097   571 layer_factory.hpp:77] Creating layer Dfc7
I1121 12:57:29.054131   571 net.cpp:91] Creating Layer Dfc7
I1121 12:57:29.054141   571 net.cpp:425] Dfc7 <- Dconv5
I1121 12:57:29.054157   571 net.cpp:399] Dfc7 -> Dfc7
I1121 12:57:29.054339   571 net.cpp:141] Setting up Dfc7
I1121 12:57:29.054352   571 net.cpp:148] Top shape: 64 1 (64)
I1121 12:57:29.054356   571 net.cpp:156] Memory required for data: 80871936
I1121 12:57:29.054365   571 layer_factory.hpp:77] Creating layer discr_loss
I1121 12:57:29.054381   571 net.cpp:91] Creating Layer discr_loss
I1121 12:57:29.054388   571 net.cpp:425] discr_loss <- Dfc7
I1121 12:57:29.054394   571 net.cpp:425] discr_loss <- label
I1121 12:57:29.054404   571 net.cpp:399] discr_loss -> discr_loss
I1121 12:57:29.054502   571 net.cpp:141] Setting up discr_loss
I1121 12:57:29.054514   571 net.cpp:148] Top shape: (1)
I1121 12:57:29.054520   571 net.cpp:151]     with loss weight 1
I1121 12:57:29.054597   571 net.cpp:156] Memory required for data: 80871940
I1121 12:57:29.054618   571 net.cpp:217] discr_loss needs backward computation.
I1121 12:57:29.054628   571 net.cpp:217] Dfc7 needs backward computation.
I1121 12:57:29.054635   571 net.cpp:217] Dconv5 needs backward computation.
I1121 12:57:29.054639   571 net.cpp:217] Drelu4 needs backward computation.
I1121 12:57:29.054644   571 net.cpp:217] Dconv4_BN needs backward computation.
I1121 12:57:29.054651   571 net.cpp:217] Dconv4 needs backward computation.
I1121 12:57:29.054656   571 net.cpp:217] Drelu3 needs backward computation.
I1121 12:57:29.054661   571 net.cpp:217] Dconv3_BN needs backward computation.
I1121 12:57:29.054666   571 net.cpp:217] Dconv3 needs backward computation.
I1121 12:57:29.054672   571 net.cpp:217] Drelu2 needs backward computation.
I1121 12:57:29.054677   571 net.cpp:217] Dconv2_BN needs backward computation.
I1121 12:57:29.054682   571 net.cpp:217] Dconv2 needs backward computation.
I1121 12:57:29.054687   571 net.cpp:217] Drelu1 needs backward computation.
I1121 12:57:29.054692   571 net.cpp:217] Dconv1 needs backward computation.
I1121 12:57:29.054698   571 net.cpp:219] input does not need backward computation.
I1121 12:57:29.054708   571 net.cpp:261] This network produces output discr_loss
I1121 12:57:29.054747   571 net.cpp:274] Network initialization done.
I1121 12:57:29.054899   571 solver.cpp:60] Solver scaffolding done.
I1121 12:57:29.056452   571 upgrade_proto.cpp:1044] Attempting to upgrade input file specified using deprecated 'solver_type' field (enum)': solver_data.prototxt
I1121 12:57:29.056463   571 upgrade_proto.cpp:1051] Successfully upgraded file specified using deprecated 'solver_type' field (enum) to 'type' field (string).
W1121 12:57:29.056464   571 upgrade_proto.cpp:1053] Note that future Caffe releases will only support 'type' field (string) for a solver's type.
I1121 12:57:29.056519   571 solver.cpp:48] Initializing solver from parameters: 
base_lr: 0.0002
display: 0
max_iter: 15000
lr_policy: "multistep"
gamma: 0.5
momentum: 0.5
weight_decay: 0.0004
solver_mode: GPU
device_id: 0
net: "data.prototxt"
stepvalue: 6000
stepvalue: 10000
stepvalue: 140000
stepvalue: 180000
stepvalue: 220000
momentum2: 0.999
type: "Adam"
I1121 12:57:29.056529   571 solver.cpp:91] Creating training net from net file: data.prototxt
I1121 12:57:29.056622   571 net.cpp:49] Initializing net from parameters: 
state {
  phase: TRAIN
}
layer {
  name: "data"
  type: "ImageData"
  top: "data"
  top: "label"
  transform_param {
    mirror: true
    mean_value: 104
    mean_value: 117
    mean_value: 123
  }
  image_data_param {
    source: "celebA.txt"
    batch_size: 64
  }
}
I1121 12:57:29.056643   571 layer_factory.hpp:77] Creating layer data
I1121 12:57:29.056656   571 net.cpp:91] Creating Layer data
I1121 12:57:29.056661   571 net.cpp:399] data -> data
I1121 12:57:29.056669   571 net.cpp:399] data -> label
I1121 12:57:29.056681   571 image_data_layer.cpp:38] Opening file celebA.txt
I1121 12:57:29.056723   571 image_data_layer.cpp:53] A total of 0 images.

something wrong with the train.py

Hi
I have compile the caffe-fr-chairs and test it. But when i try to run the train.py , i find some problems about it:

  1. i cannot understand the use of 'net.forward_simple' and 'net.backward_simple' and never find it in google.
  2. There is a valueerror in line 78, which note that "could not broadcast input array from shape (64,3,218,178) into shape (64,3,64,64)"
    could you give me some guidance to solve that ??
    thank you!!

Defining different discriminator-loss

Hi, thanks for your work.
Could you explain the reason for defining discr_real_loss, discr_fake_loss and discr_real_for_generator_loss in train.py. I can not understand the their differences, specifically input 'data' and 'label'.
Thank you very much!

AttributeError: 'Net' object has no attribute...

Hi,
I am glade to find a caffe-based GAN implementation.
I installed the caffe deepsim-caffe-branch branch and compiled it. When I run
print "Caffe path:", caffe.__file__
I obtain ~/gan-caffe/python/caffe/__init__.pyc
which is the path of this branch in my pc

I have declared

generator = caffe.AdamSolver('solver_generator.prototxt')
discriminator = caffe.AdamSolver('solver_discriminator.prototxt')

However, when I run the train.py I keep having the following errors

    discriminator.net.forward_simple()
AttributeError: 'Net' object has no attribute 'forward_simple'

    generator.increment_iter()
AttributeError: 'AdamSolver' object has no attribute 'increment_iter'

    generator.net.clear_param_diffs()
AttributeError: 'Net' object has no attribute 'clear_param_diffs'

And the same error practically with all functions.
When I changed forward_simple() to forward() and backward_simple() to backward() it worked!

Thank you for the help

'Net' object has no attribute '_blob_names_index'

Hello,
I have one problem when running your code in train.py, line 60.

discr_loss_weight = discriminator.net._blob_loss_weights[discriminator.net._blob_names_index['discr_loss']]

I got AttributeError, 'Net' object has no attribute '_blob_names_index'
How can I run this code correctly?

Only updating discriminator on generated data

I am trying to understand this code but I'm not quite getting how it works. In train.py you do a forward and backward pass of the discriminator with batches of real data and generated data, but you only call apply_update() after seeing generated data. Doesn't this mean the discriminator is never trained to classify real data, so the generated data won't necessarily match the real data distribution? But the output images seem realistic so I'm not sure what I'm missing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.