Code Monkey home page Code Monkey logo

dcgan's Introduction

GitHub last commit (branch) Supported TF Version Documentation Status Build Status Downloads Downloads Docker Pulls Codacy Badge

Please click TensorLayerX 🔥🔥🔥

TensorLayer is a novel TensorFlow-based deep learning and reinforcement learning library designed for researchers and engineers. It provides an extensive collection of customizable neural layers to build advanced AI models quickly, based on this, the community open-sourced mass tutorials and applications. TensorLayer is awarded the 2017 Best Open Source Software by the ACM Multimedia Society. This project can also be found at OpenI and Gitee.

News

  • 🔥 TensorLayerX is a Unified Deep Learning and Reinforcement Learning Framework for All Hardwares, Backends and OS. The current version supports TensorFlow, Pytorch, MindSpore, PaddlePaddle, OneFlow and Jittor as the backends, allowing users to run the code on different hardware like Nvidia-GPU and Huawei-Ascend.
  • TensorLayer is now in OpenI
  • Reinforcement Learning Zoo: Low-level APIs for professional usage, High-level APIs for simple usage, and a corresponding Springer textbook
  • Sipeed Maxi-EMC: Run TensorLayer models on the low-cost AI chip (e.g., K210) (Alpha Version)

Design Features

TensorLayer is a new deep learning library designed with simplicity, flexibility and high-performance in mind.

  • Simplicity : TensorLayer has a high-level layer/model abstraction which is effortless to learn. You can learn how deep learning can benefit your AI tasks in minutes through the massive examples.
  • Flexibility : TensorLayer APIs are transparent and flexible, inspired by the emerging PyTorch library. Compared to the Keras abstraction, TensorLayer makes it much easier to build and train complex AI models.
  • Zero-cost Abstraction : Though simple to use, TensorLayer does not require you to make any compromise in the performance of TensorFlow (Check the following benchmark section for more details).

TensorLayer stands at a unique spot in the TensorFlow wrappers. Other wrappers like Keras and TFLearn hide many powerful features of TensorFlow and provide little support for writing custom AI models. Inspired by PyTorch, TensorLayer APIs are simple, flexible and Pythonic, making it easy to learn while being flexible enough to cope with complex AI tasks. TensorLayer has a fast-growing community. It has been used by researchers and engineers all over the world, including those from Peking University, Imperial College London, UC Berkeley, Carnegie Mellon University, Stanford University, and companies like Google, Microsoft, Alibaba, Tencent, Xiaomi, and Bloomberg.

Multilingual Documents

TensorLayer has extensive documentation for both beginners and professionals. The documentation is available in both English and Chinese.

English Documentation Chinese Documentation Chinese Book

If you want to try the experimental features on the the master branch, you can find the latest document here.

Extensive Examples

You can find a large collection of examples that use TensorLayer in here and the following space:

Getting Start

TensorLayer 2.0 relies on TensorFlow, numpy, and others. To use GPUs, CUDA and cuDNN are required.

Install TensorFlow:

pip3 install tensorflow-gpu==2.0.0-rc1 # TensorFlow GPU (version 2.0 RC1)
pip3 install tensorflow # CPU version

Install the stable release of TensorLayer:

pip3 install tensorlayer

Install the unstable development version of TensorLayer:

pip3 install git+https://github.com/tensorlayer/tensorlayer.git

If you want to install the additional dependencies, you can also run

pip3 install --upgrade tensorlayer[all]              # all additional dependencies
pip3 install --upgrade tensorlayer[extra]            # only the `extra` dependencies
pip3 install --upgrade tensorlayer[contrib_loggers]  # only the `contrib_loggers` dependencies

If you are TensorFlow 1.X users, you can use TensorLayer 1.11.0:

# For last stable version of TensorLayer 1.X
pip3 install --upgrade tensorlayer==1.11.0

Performance Benchmark

The following table shows the training speeds of VGG16 using TensorLayer and native TensorFlow on a TITAN Xp.

Mode Lib Data Format Max GPU Memory Usage(MB) Max CPU Memory Usage(MB) Avg CPU Memory Usage(MB) Runtime (sec)
AutoGraph TensorFlow 2.0 channel last 11833 2161 2136 74
TensorLayer 2.0 channel last 11833 2187 2169 76
Graph Keras channel last 8677 2580 2576 101
Eager TensorFlow 2.0 channel last 8723 2052 2024 97
TensorLayer 2.0 channel last 8723 2010 2007 95

Getting Involved

Please read the Contributor Guideline before submitting your PRs.

We suggest users to report bugs using Github issues. Users can also discuss how to use TensorLayer in the following slack channel.



Citing TensorLayer

If you find TensorLayer useful for your project, please cite the following papers:

@article{tensorlayer2017,
    author  = {Dong, Hao and Supratak, Akara and Mai, Luo and Liu, Fangde and Oehmichen, Axel and Yu, Simiao and Guo, Yike},
    journal = {ACM Multimedia},
    title   = {{TensorLayer: A Versatile Library for Efficient Deep Learning Development}},
    url     = {http://tensorlayer.org},
    year    = {2017}
}

@inproceedings{tensorlayer2021,
  title={Tensorlayer 3.0: A Deep Learning Library Compatible With Multiple Backends},
  author={Lai, Cheng and Han, Jiarong and Dong, Hao},
  booktitle={2021 IEEE International Conference on Multimedia \& Expo Workshops (ICMEW)},
  pages={1--3},
  year={2021},
  organization={IEEE}
}

dcgan's People

Contributors

hanjr92 avatar luomai avatar pskrunner14 avatar yzwxx avatar zsdonghao 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dcgan's Issues

local variable 'z' referenced before assignment

I have this error! can you help me, please?

WARNING: Logging before flag parsing goes to stderr.
I0718 14:45:17.243686 140030963623808 tl_logging.py:99] [!] checkpoint exists ...
I0718 14:45:17.247771 140030963623808 tl_logging.py:99] [!] samples exists ...
W0718 14:45:19.318463 140030963623808 deprecation.py:323] From /usr/local/lib/python3.6/dist-packages/tensorflow/python/data/ops/dataset_ops.py:505: py_func (from tensorflow.python.ops.script_ops) is deprecated and will be removed in a future version.
Instructions for updating:
tf.py_func is deprecated in TF V2. Instead, there are two
options available in V2.
- tf.py_function takes a python function which manipulates tf eager
tensors instead of numpy arrays. It's easy to convert a tf eager tensor to
an ndarray (just call tensor.numpy()) but having access to eager tensors
means tf.py_functions can use accelerators such as GPUs as well as
being differentiable using a gradient tape.
- tf.numpy_function maintains the semantics of the deprecated tf.py_func
(it is not differentiable, and manipulates numpy arrays). It drops the
stateful argument making all functions stateful.

I0718 14:45:19.464441 140030963623808 tl_logging.py:99] Input _inputlayer_1: [None, 100]
I0718 14:45:19.974161 140030963623808 tl_logging.py:99] Dense dense_1: 8192 No Activation
I0718 14:45:20.649731 140030963623808 tl_logging.py:99] Reshape reshape_1
I0718 14:45:20.707117 140030963623808 tl_logging.py:99] BatchNorm batchnorm_1: decay: 0.900000 epsilon: 0.000010 act: relu is_train: False
I0718 14:45:20.782280 140030963623808 tl_logging.py:99] DeConv2d deconv2d_1: n_filters: 256 strides: (2, 2) padding: SAME act: No Activation dilation: (1, 1)
I0718 14:45:22.796400 140030963623808 tl_logging.py:99] BatchNorm batchnorm2d_1: decay: 0.900000 epsilon: 0.000010 act: relu is_train: False
I0718 14:45:22.873876 140030963623808 tl_logging.py:99] DeConv2d deconv2d_2: n_filters: 128 strides: (2, 2) padding: SAME act: No Activation dilation: (1, 1)
I0718 14:45:23.076492 140030963623808 tl_logging.py:99] BatchNorm batchnorm2d_2: decay: 0.900000 epsilon: 0.000010 act: relu is_train: False
I0718 14:45:23.153287 140030963623808 tl_logging.py:99] DeConv2d deconv2d_3: n_filters: 64 strides: (2, 2) padding: SAME act: No Activation dilation: (1, 1)
I0718 14:45:23.227763 140030963623808 tl_logging.py:99] BatchNorm batchnorm2d_3: decay: 0.900000 epsilon: 0.000010 act: relu is_train: False
I0718 14:45:23.307783 140030963623808 tl_logging.py:99] DeConv2d deconv2d_4: n_filters: 3 strides: (2, 2) padding: SAME act: tanh dilation: (1, 1)
I0718 14:45:23.390201 140030963623808 tl_logging.py:99] Input _inputlayer_2: [None, 64, 64, 3]
I0718 14:45:23.456669 140030963623808 tl_logging.py:99] Conv2d conv2d_1: n_filter: 64 filter_size: (5, 5) strides: (2, 2) pad: SAME act:
I0718 14:45:23.530629 140030963623808 tl_logging.py:99] Conv2d conv2d_2: n_filter: 128 filter_size: (5, 5) strides: (2, 2) pad: SAME act: No Activation
I0718 14:45:23.608061 140030963623808 tl_logging.py:99] BatchNorm batchnorm2d_4: decay: 0.900000 epsilon: 0.000010 act: is_train: False
I0718 14:45:23.691769 140030963623808 tl_logging.py:99] Conv2d conv2d_3: n_filter: 256 filter_size: (5, 5) strides: (2, 2) pad: SAME act: No Activation
I0718 14:45:23.775271 140030963623808 tl_logging.py:99] BatchNorm batchnorm2d_5: decay: 0.900000 epsilon: 0.000010 act: is_train: False
I0718 14:45:23.942049 140030963623808 tl_logging.py:99] Conv2d conv2d_4: n_filter: 512 filter_size: (5, 5) strides: (2, 2) pad: SAME act: No Activation
I0718 14:45:24.041154 140030963623808 tl_logging.py:99] BatchNorm batchnorm2d_6: decay: 0.900000 epsilon: 0.000010 act: is_train: False
I0718 14:45:24.114703 140030963623808 tl_logging.py:99] Flatten flatten_1:
I0718 14:45:24.177696 140030963623808 tl_logging.py:99] Dense dense_2: 1 identity
I0718 14:45:29.721007 140030963623808 tl_logging.py:99] [] Saving TL weights into checkpoint/G.npz
I0718 14:45:31.268130 140030963623808 tl_logging.py:99] [
] Saved
I0718 14:45:31.274845 140030963623808 tl_logging.py:99] [] Saving TL weights into checkpoint/D.npz
I0718 14:45:32.590787 140030963623808 tl_logging.py:99] [
] Saved

UnboundLocalError Traceback (most recent call last)
in ()
58
59 if name == 'main':
---> 60 train()

in train()
53 D.save_weights('{}/D.npz'.format(flags.checkpoint_dir), format='npz')
54 G.eval()
---> 55 result = G(z)
56 G.train()
57 tl.visualize.save_images(result.numpy(), [num_tiles, num_tiles], '{}/train_{:02d}.png'.format(flags.sample_dir, epoch))

UnboundLocalError: local variable 'z' referenced before assignment

how to generate new images

Hi
Does any one know how to generate new images? There is no file to test the images and generate samples.

Thanks in advance

Error running train.py

Running train.py i get the following error:

Traceback (most recent call last):
  File "train.py", line 60, in <module>
    train()
  File "train.py", line 44, in train
    grad = tape.gradient(g_loss, G.trainable_weights)
AttributeError: 'Model' object has no attribute 'trainable_weights'

am i running a wrong version of tensorflow/tensorlayer (2.0.0a0/2.0.0)?

--sample_size option causes ValueError

When I pass --sample_size 256 as a flag to main.py, I get

ValueError: Cannot feed value of shape (256, 100) for Tensor 'z_noise:0', which has shape '(64, 100)'

When I pass --sample_size 256 and --batch_size 256, the code went into an endless loop just saying "Sample images updated!" without running each epoch.

Error during run

I can't seem to understand the error I am getting while running the main.py

Use tf.global_variables_initializer instead.
Traceback (most recent call last):
File "D:\anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1139, in _do_call
return fn(*args)
File "D:\anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1121, in _run_fn
status, run_metadata)
File "D:\anaconda3\lib\contextlib.py", line 88, in exit
next(self.gen)
File "D:\anaconda3\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot assign a device for operation 'generator/g/h4/decon2d/b_deconv2d/Adam_1': Operation was explicitly assigned to /device:GPU:0 but available devices are [ /job:localhost/replica:0/task:0/cpu:0 ]. Make sure the device specification refers to a valid device.
[[Node: generator/g/h4/decon2d/b_deconv2d/Adam_1 = VariableV2_class=["loc:@generator/g/h4/decon2d/b_deconv2d"], container="", dtype=DT_FLOAT, shape=[3], shared_name="", _device="/device:GPU:0"]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\smyrniou\dcgan-master\tensorlayer\layers.py", line 235, in initialize_global_variables
sess.run(tf.global_variables_initializer())
File "D:\anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 789, in run
run_metadata_ptr)
File "D:\anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 997, in _run
feed_dict_string, options, run_metadata)
File "D:\anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1132, in _do_run
target_list, options, run_metadata)
File "D:\anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1152, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot assign a device for operation 'generator/g/h4/decon2d/b_deconv2d/Adam_1': Operation was explicitly assigned to /device:GPU:0 but available devices are [ /job:localhost/replica:0/task:0/cpu:0 ]. Make sure the device specification refers to a valid device.
[[Node: generator/g/h4/decon2d/b_deconv2d/Adam_1 = VariableV2_class=["loc:@generator/g/h4/decon2d/b_deconv2d"], container="", dtype=DT_FLOAT, shape=[3], shared_name="", _device="/device:GPU:0"]]

Caused by op 'generator/g/h4/decon2d/b_deconv2d/Adam_1', defined at:
File "C:/Users/smyrniou/dcgan-master/main.py", line 145, in
tf.app.run()
File "D:\anaconda3\lib\site-packages\tensorflow\python\platform\app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "C:/Users/smyrniou/dcgan-master/main.py", line 82, in main
.minimize(g_loss, var_list=g_vars)
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\optimizer.py", line 325, in minimize
name=name)
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\optimizer.py", line 446, in apply_gradients
self._create_slots([_get_variable_for(v) for v in var_list])
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\adam.py", line 129, in _create_slots
self._zeros_slot(v, "v", self._name)
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\optimizer.py", line 766, in _zeros_slot
named_slots[_var_key(var)] = slot_creator.create_zeros_slot(var, op_name)
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\slot_creator.py", line 174, in create_zeros_slot
colocate_with_primary=colocate_with_primary)
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\slot_creator.py", line 146, in create_slot_with_initializer
dtype)
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\slot_creator.py", line 66, in _create_slot_var
validate_shape=validate_shape)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 1065, in get_variable
use_resource=use_resource, custom_getter=custom_getter)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 962, in get_variable
use_resource=use_resource, custom_getter=custom_getter)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 367, in get_variable
validate_shape=validate_shape, use_resource=use_resource)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 352, in _true_getter
use_resource=use_resource)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 725, in _get_single_variable
validate_shape=validate_shape)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variables.py", line 200, in init
expected_shape=expected_shape)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variables.py", line 284, in _init_from_args
name=name)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\state_ops.py", line 128, in variable_op_v2
shared_name=shared_name)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\gen_state_ops.py", line 684, in _variable_v2
name=name)
File "D:\anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 767, in apply_op
op_def=op_def)
File "D:\anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 2506, in create_op
original_op=self._default_original_op, op_def=op_def)
File "D:\anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1269, in init
self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): Cannot assign a device for operation 'generator/g/h4/decon2d/b_deconv2d/Adam_1': Operation was explicitly assigned to /device:GPU:0 but available devices are [ /job:localhost/replica:0/task:0/cpu:0 ]. Make sure the device specification refers to a valid device.
[[Node: generator/g/h4/decon2d/b_deconv2d/Adam_1 = VariableV2_class=["loc:@generator/g/h4/decon2d/b_deconv2d"], container="", dtype=DT_FLOAT, shape=[3], shared_name="", _device="/device:GPU:0"]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1139, in _do_call
return fn(*args)
File "D:\anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1121, in _run_fn
status, run_metadata)
File "D:\anaconda3\lib\contextlib.py", line 88, in exit
next(self.gen)
File "D:\anaconda3\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot assign a device for operation 'generator/g/h4/decon2d/b_deconv2d/Adam_1': Operation was explicitly assigned to /device:GPU:0 but available devices are [ /job:localhost/replica:0/task:0/cpu:0 ]. Make sure the device specification refers to a valid device.
[[Node: generator/g/h4/decon2d/b_deconv2d/Adam_1 = VariableV2_class=["loc:@generator/g/h4/decon2d/b_deconv2d"], container="", dtype=DT_FLOAT, shape=[3], shared_name="", _device="/device:GPU:0"]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/smyrniou/dcgan-master/main.py", line 145, in
tf.app.run()
File "D:\anaconda3\lib\site-packages\tensorflow\python\platform\app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "C:/Users/smyrniou/dcgan-master/main.py", line 85, in main
tl.layers.initialize_global_variables(sess)
File "C:\Users\smyrniou\dcgan-master\tensorlayer\layers.py", line 237, in initialize_global_variables
sess.run(tf.initialize_all_variables())
File "D:\anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 789, in run
run_metadata_ptr)
File "D:\anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 997, in _run
feed_dict_string, options, run_metadata)
File "D:\anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1132, in _do_run
target_list, options, run_metadata)
File "D:\anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1152, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot assign a device for operation 'generator/g/h4/decon2d/b_deconv2d/Adam_1': Operation was explicitly assigned to /device:GPU:0 but available devices are [ /job:localhost/replica:0/task:0/cpu:0 ]. Make sure the device specification refers to a valid device.
[[Node: generator/g/h4/decon2d/b_deconv2d/Adam_1 = VariableV2_class=["loc:@generator/g/h4/decon2d/b_deconv2d"], container="", dtype=DT_FLOAT, shape=[3], shared_name="", _device="/device:GPU:0"]]

Caused by op 'generator/g/h4/decon2d/b_deconv2d/Adam_1', defined at:
File "C:/Users/smyrniou/dcgan-master/main.py", line 145, in
tf.app.run()
File "D:\anaconda3\lib\site-packages\tensorflow\python\platform\app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "C:/Users/smyrniou/dcgan-master/main.py", line 82, in main
.minimize(g_loss, var_list=g_vars)
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\optimizer.py", line 325, in minimize
name=name)
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\optimizer.py", line 446, in apply_gradients
self._create_slots([_get_variable_for(v) for v in var_list])
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\adam.py", line 129, in _create_slots
self._zeros_slot(v, "v", self._name)
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\optimizer.py", line 766, in _zeros_slot
named_slots[_var_key(var)] = slot_creator.create_zeros_slot(var, op_name)
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\slot_creator.py", line 174, in create_zeros_slot
colocate_with_primary=colocate_with_primary)
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\slot_creator.py", line 146, in create_slot_with_initializer
dtype)
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\slot_creator.py", line 66, in _create_slot_var
validate_shape=validate_shape)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 1065, in get_variable
use_resource=use_resource, custom_getter=custom_getter)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 962, in get_variable
use_resource=use_resource, custom_getter=custom_getter)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 367, in get_variable
validate_shape=validate_shape, use_resource=use_resource)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 352, in _true_getter
use_resource=use_resource)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 725, in _get_single_variable
validate_shape=validate_shape)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variables.py", line 200, in init
expected_shape=expected_shape)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variables.py", line 284, in _init_from_args
name=name)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\state_ops.py", line 128, in variable_op_v2
shared_name=shared_name)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\gen_state_ops.py", line 684, in _variable_v2
name=name)
File "D:\anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 767, in apply_op
op_def=op_def)
File "D:\anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 2506, in create_op
original_op=self._default_original_op, op_def=op_def)
File "D:\anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1269, in init
self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): Cannot assign a device for operation 'generator/g/h4/decon2d/b_deconv2d/Adam_1': Operation was explicitly assigned to /device:GPU:0 but available devices are [ /job:localhost/replica:0/task:0/cpu:0 ]. Make sure the device specification refers to a valid device.
[[Node: generator/g/h4/decon2d/b_deconv2d/Adam_1 = VariableV2_class=["loc:@generator/g/h4/decon2d/b_deconv2d"], container="", dtype=DT_FLOAT, shape=[3], shared_name="", _device="/device:GPU:0"]]

extract features

@zsdonghao How can i use discriminator layers to take a vector of features for every image in own dataset not celeba?. As paragraph 5.1 in "UNSUPERVISED REPRESENTATION LEARNING WITH DEEP CONVOLUTIONAL GENERATIVE ADVERSARIAL NETWORKS"

multi-gpu

how can i run the code on multi-gpu

TypeError when run main.py

Tried both the dcgan folder version of tensorlayer (1.4.5) and installed version of tensorlayer (1.8.1).
tensorflow version is 1.6.0.

$ python main.py 
/home/ly/anaconda3/envs/learning/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
Traceback (most recent call last):
  File "/home/ly/anaconda3/envs/learning/lib/python3.6/site-packages/absl/flags/_flag.py", line 166, in _parse
    return self.parser.parse(argument)
  File "/home/ly/anaconda3/envs/learning/lib/python3.6/site-packages/absl/flags/_argument_parser.py", line 152, in parse
    val = self.convert(argument)
  File "/home/ly/anaconda3/envs/learning/lib/python3.6/site-packages/absl/flags/_argument_parser.py", line 268, in convert
    type(argument)))
TypeError: Expect argument to be a string or int, found <class 'float'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 23, in <module>
    flags.DEFINE_integer("train_size", np.inf, "The size of train images [np.inf]")
  File "/home/ly/anaconda3/envs/learning/lib/python3.6/site-packages/tensorflow/python/platform/flags.py", line 58, in wrapper
    return original_function(*args, **kwargs)
  File "/home/ly/anaconda3/envs/learning/lib/python3.6/site-packages/absl/flags/_defines.py", line 315, in DEFINE_integer
    DEFINE(parser, name, default, help, flag_values, serializer, **args)
  File "/home/ly/anaconda3/envs/learning/lib/python3.6/site-packages/absl/flags/_defines.py", line 81, in DEFINE
    DEFINE_flag(_flag.Flag(parser, serializer, name, default, help, **args),
  File "/home/ly/anaconda3/envs/learning/lib/python3.6/site-packages/absl/flags/_flag.py", line 107, in __init__
    self._set_default(default)
  File "/home/ly/anaconda3/envs/learning/lib/python3.6/site-packages/absl/flags/_flag.py", line 196, in _set_default
    self.default = self._parse(value)
  File "/home/ly/anaconda3/envs/learning/lib/python3.6/site-packages/absl/flags/_flag.py", line 169, in _parse
    'flag --%s=%s: %s' % (self.name, argument, e))
absl.flags._exceptions.IllegalFlagValueError: flag --train_size=inf: Expect argument to be a string or int, found <class 'float'>

ValueError: Trying to share variable discriminator/d/h4/lin_sigmoid/W

hi,
I use:
Tensorflow V 1.10 CPU version
Tensorlayer V 1.10.1
python 3.6
windows 10

after run : python main.py I get ValueError

Traceback (most recent call last):
File "c:/Users/USER/Desktop/פרוייקט תואר שני/playgroung/dcgan/main.py", line 166, in
tf.app.run()
File "C:\Python\3.6\lib\site-packages\tensorflow\python\platform\app.py", line 125, in run
_sys.exit(main(argv))
File "c:/Users/USER/Desktop/פרוייקט תואר שני/playgroung/dcgan/main.py", line 59, in main
_, d2_logits = discriminator(real_images, is_train=True, reuse=True)
File "c:\Users\USER\Desktop\פרוייקט תואר שני\playgroung\dcgan\model.py", line 81, in discriminator
W_init = w_init, name='d/h4/lin_sigmoid')
File "c:\Users\USER\Desktop\פרוייקט תואר שני\playgroung\dcgan\tensorlayer\layers\core.py", line 926, in init
W = tf.get_variable(name='W', shape=(n_in, n_units), initializer=W_init, dtype=LayersConfig.tf_dtype, **W_init_args)
File "C:\Python\3.6\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 1467, in get_variable
aggregation=aggregation)
File "C:\Python\3.6\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 1217, in get_variable
aggregation=aggregation)
File "C:\Python\3.6\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 527, in get_variable
aggregation=aggregation)
File "C:\Python\3.6\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 481, in _true_getter
aggregation=aggregation)
File "C:\Python\3.6\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 853, in _get_single_variable
found_var.get_shape()))
ValueError: Trying to share variable discriminator/d/h4/lin_sigmoid/W, but specified shape (8192, 1) and found shape (2048, 1).

Performance issue in /data.py (by P3)

Hello! I've found a performance issue in /data.py: ds.batch(batch_size)(here) should be called before ds.map(_map_fn, num_parallel_calls=4)(here), which could make your program more efficient.

Here is the tensorflow document to support it.

Besides, you need to check the function _map_fn called in ds.map(_map_fn, num_parallel_calls=4) whether to be affected or not to make the changed code work properly. For example, if _map_fn needs data with shape (x, y, z) as its input before fix, it would require data with shape (batch_size, x, y, z) after fix.

Looking forward to your reply. Btw, I am very glad to create a PR to fix it if you are too busy.

The url for CelebA dose not work now

The url for CelebA dataset in download.py dose not work now because of the dropbox problem.
So It's better to change it to the url of google-drive or baidu-drive.

Error during download

Tried twice, same error.

python download.py celebA
./data/img_align_celeba.zip: 25.5kB [12:15, 34.7B/s]Traceback (most recent call last):
  File "/home/ly/anaconda3/envs/learning/lib/python3.6/site-packages/urllib3/response.py", line 302, in _error_catcher
    yield
  File "/home/ly/anaconda3/envs/learning/lib/python3.6/site-packages/urllib3/response.py", line 601, in read_chunked
    chunk = self._handle_chunk(amt)
  File "/home/ly/anaconda3/envs/learning/lib/python3.6/site-packages/urllib3/response.py", line 557, in _handle_chunk
    value = self._fp._safe_read(amt)
  File "/home/ly/anaconda3/envs/learning/lib/python3.6/http/client.py", line 614, in _safe_read
    raise IncompleteRead(b''.join(s), amt)
http.client.IncompleteRead: IncompleteRead(5887 bytes read, 26881 more expected)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ly/anaconda3/envs/learning/lib/python3.6/site-packages/requests/models.py", line 745, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "/home/ly/anaconda3/envs/learning/lib/python3.6/site-packages/urllib3/response.py", line 432, in stream
    for line in self.read_chunked(amt, decode_content=decode_content):
  File "/home/ly/anaconda3/envs/learning/lib/python3.6/site-packages/urllib3/response.py", line 626, in read_chunked
    self._original_response.close()
  File "/home/ly/anaconda3/envs/learning/lib/python3.6/contextlib.py", line 99, in __exit__
    self.gen.throw(type, value, traceback)
  File "/home/ly/anaconda3/envs/learning/lib/python3.6/site-packages/urllib3/response.py", line 320, in _error_catcher
    raise ProtocolError('Connection broken: %r' % e, e)
urllib3.exceptions.ProtocolError: ('Connection broken: IncompleteRead(5887 bytes read, 26881 more expected)', IncompleteRead(5887 bytes read, 26881 more expected))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "download.py", line 164, in <module>
    download_celeb_a('./data')
  File "download.py", line 91, in download_celeb_a
    download_file_from_google_drive(drive_id, save_path)
  File "download.py", line 56, in download_file_from_google_drive
    save_response_content(response, destination)
  File "download.py", line 68, in save_response_content
    unit='B', unit_scale=True, desc=destination):
  File "/home/ly/anaconda3/envs/learning/lib/python3.6/site-packages/tqdm/_tqdm.py", line 962, in __iter__
    for obj in iterable:
  File "/home/ly/anaconda3/envs/learning/lib/python3.6/site-packages/requests/models.py", line 748, in generate
    raise ChunkedEncodingError(e)
requests.exceptions.ChunkedEncodingError: ('Connection broken: IncompleteRead(5887 bytes read, 26881 more expected)', IncompleteRead(5887 bytes read, 26881 more expected))

Traceback error - main.py

Trying to run main.py and I get the following error.

traceback (most recent call last):
  File "main.py", line 23, in <module>
    flags.DEFINE_integer("train_size", np.inf, "The size of train images [np.inf]")
  File "/anaconda2/lib/python2.7/site-packages/tensorflow/python/platform/flags.py", line 58, in wrapper
    return original_function(*args, **kwargs)
  File "/anaconda2/lib/python2.7/site-packages/absl/flags/_defines.py", line 315, in DEFINE_integer
    DEFINE(parser, name, default, help, flag_values, serializer, **args)
  File "/anaconda2/lib/python2.7/site-packages/absl/flags/_defines.py", line 81, in DEFINE
    DEFINE_flag(_flag.Flag(parser, serializer, name, default, help, **args),
  File "/anaconda2/lib/python2.7/site-packages/absl/flags/_flag.py", line 107, in __init__
    self._set_default(default)
  File "/anaconda2/lib/python2.7/site-packages/absl/flags/_flag.py", line 196, in _set_default
    self.default = self._parse(value)
  File "/anaconda2/lib/python2.7/site-packages/absl/flags/_flag.py", line 169, in _parse
    'flag --%s=%s: %s' % (self.name, argument, e))
absl.flags._exceptions.IllegalFlagValueError: flag --train_size=inf: Expect argument to be a string or int, found <type 'float'>

Has anyone else encountered this?

How to train on existing checkpoint

I would like to train on an existing saved checkpoint but it seems the GAN learn from scratches.

Is there some way to load a existing checkpoint ?

Thanks in advance.

TypeError: __init__() got multiple values for keyword argument 'dtype'

When I try to run the repository to realize dcgan(After running python download.py mnist successfully, when running python main.py), I meet the problem as follows.

`Traceback (most recent call last):

File "main.py", line 418, in
tf.app.run()
File "/home/pcserver/anaconda2/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 44, in run

_sys.exit(main(_sys.argv[:1] + flags_passthrough))

File "main.py", line 290, in main
net_g, g_logits = generator_simplified_api(z, is_train=True, reuse=False)

File "main.py", line 104, in generator_simplified_api
gamma_init=gamma_init, name='g/h0/batch_norm')

File "/home/pcserver/car/dcgan-master/tensorlayer/layers.py", line 1732, in init
initializer=beta_init)

File "/home/pcserver/car/dcgan-master/tensorlayer/layers.py", line 1717, in _get_variable
trainable=trainable)

File "/home/pcserver/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 988, in get_variable
custom_getter=custom_getter)

File "/home/pcserver/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 890, in get_variable
custom_getter=custom_getter)

File "/home/pcserver/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 348, in get_variable
validate_shape=validate_shape)

File "/home/pcserver/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 333, in _true_getter
caching_device=caching_device, validate_shape=validate_shape)

File "/home/pcserver/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 684, in _get_single_variable
validate_shape=validate_shape)

File "/home/pcserver/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/variables.py", line 226, in init
expected_shape=expected_shape)

File "/home/pcserver/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/variables.py", line 303, in _init_from_args
initial_value(), name="initial_value", dtype=dtype)

File "/home/pcserver/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 673, in
shape.as_list(), dtype=dtype, partition_info=partition_info)

TypeError: init() got multiple values for keyword argument 'dtype'`

The bold text "init" should be shown as "init" surrouded by two underline.

I cannot find any useful information on google to solve it, so I hope you will help me. @zsdonghao
To make my question clear, my environment is tensorflow 1.0.1. Before that , I have replaced tf.nn.rnn_cell with tf.contrib.rnn to solve the question "No module object named rnn_cell".
And now, this new question makes me stopped.

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.