Coder Social home page Coder Social logo

gan's Introduction

Python PyPI DOI CII Best Practices OpenSSF Scorecard Fuzzing Status Fuzzing Status OSSRank Contributor Covenant TF Official Continuous TF Official Nightly

Documentation
Documentation

TensorFlow is an end-to-end open source platform for machine learning. It has a comprehensive, flexible ecosystem of tools, libraries, and community resources that lets researchers push the state-of-the-art in ML and developers easily build and deploy ML-powered applications.

TensorFlow was originally developed by researchers and engineers working within the Machine Intelligence team at Google Brain to conduct research in machine learning and neural networks. However, the framework is versatile enough to be used in other areas as well.

TensorFlow provides stable Python and C++ APIs, as well as a non-guaranteed backward compatible API for other languages.

Keep up-to-date with release announcements and security updates by subscribing to [email protected]. See all the mailing lists.

Install

See the TensorFlow install guide for the pip package, to enable GPU support, use a Docker container, and build from source.

To install the current release, which includes support for CUDA-enabled GPU cards (Ubuntu and Windows):

$ pip install tensorflow

Other devices (DirectX and MacOS-metal) are supported using Device plugins.

A smaller CPU-only package is also available:

$ pip install tensorflow-cpu

To update TensorFlow to the latest version, add --upgrade flag to the above commands.

Nightly binaries are available for testing using the tf-nightly and tf-nightly-cpu packages on PyPi.

Try your first TensorFlow program

$ python
>>> import tensorflow as tf
>>> tf.add(1, 2).numpy()
3
>>> hello = tf.constant('Hello, TensorFlow!')
>>> hello.numpy()
b'Hello, TensorFlow!'

For more examples, see the TensorFlow tutorials.

Contribution guidelines

If you want to contribute to TensorFlow, be sure to review the contribution guidelines. This project adheres to TensorFlow's code of conduct. By participating, you are expected to uphold this code.

We use GitHub issues for tracking requests and bugs, please see TensorFlow Forum for general questions and discussion, and please direct specific questions to Stack Overflow.

The TensorFlow project strives to abide by generally accepted best practices in open-source software development.

Patching guidelines

Follow these steps to patch a specific version of TensorFlow, for example, to apply fixes to bugs or security vulnerabilities:

  • Clone the TensorFlow repo and switch to the corresponding branch for your desired TensorFlow version, for example, branch r2.8 for version 2.8.
  • Apply (that is, cherry-pick) the desired changes and resolve any code conflicts.
  • Run TensorFlow tests and ensure they pass.
  • Build the TensorFlow pip package from source.

Continuous build status

You can find more community-supported platforms and configurations in the TensorFlow SIG Build community builds table.

Official Builds

Build Type Status Artifacts
Linux CPU Status PyPI
Linux GPU Status PyPI
Linux XLA Status TBA
macOS Status PyPI
Windows CPU Status PyPI
Windows GPU Status PyPI
Android Status Download
Raspberry Pi 0 and 1 Status Py3
Raspberry Pi 2 and 3 Status Py3
Libtensorflow MacOS CPU Status Temporarily Unavailable Nightly Binary Official GCS
Libtensorflow Linux CPU Status Temporarily Unavailable Nightly Binary Official GCS
Libtensorflow Linux GPU Status Temporarily Unavailable Nightly Binary Official GCS
Libtensorflow Windows CPU Status Temporarily Unavailable Nightly Binary Official GCS
Libtensorflow Windows GPU Status Temporarily Unavailable Nightly Binary Official GCS

Resources

Learn more about the TensorFlow community and how to contribute.

Courses

License

Apache License 2.0

gan's People

Contributors

aaronsarna avatar conchylicultor avatar csuter avatar ebrevdo avatar fchollet avatar hertschuh avatar joel-shor avatar ldonoughe avatar marbiru avatar nivedwho avatar pierrot0 avatar renha avatar saxenasaurabh avatar superbobry avatar vsubhashini avatar yilei avatar yongjun823 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  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

gan's Issues

How to apply identity loss in cyclegan model?

Hello, now I'm using the cyclegan model in tfgan as the base of my network, but from the original CycleGAN paper, there is an identity loss in additional to cycle consistency loss, I'm getting trouble in adding this loss to your cyclegan model. Could you give me some hints that where I can apply this loss?

Spinoff Tensorflow GAN does not work in 2.X version

Bug report for Colab: http://colab.research.google.com/.

For questions about colab usage, please use stackoverflow.

Describe the current behavior:
It has multiple problems:
First This code Segment makes a call to multiple libraries and functions
---- Original code in the notebook
import matplotlib.pyplot as plt
import tensorflow_datasets as tfds
import tensorflow_gan as tfgan
import numpy as np
params = {'batch_size': 100, 'noise_dims':64}
with tf.Graph().as_default():
ds = input_fn(tf.estimator.ModeKeys.TRAIN, params)
numpy_imgs = next(tfds.as_numpy(ds))[1]
img_grid = tfgan.eval.python_image_grid(numpy_imgs, grid_shape=(10, 10))
plt.axis('off')
plt.imshow(np.squeeze(img_grid))
plt.show()
--------------------- Error that arises ---
AttributeError Traceback (most recent call last)
in (_)
12
13 noise_ds = (tf.data.Dataset.from_tensors(0).repeat()
---> 14 .map(lambda _: tf.random_normal([bs, nd])))
15
16 if just_noise:

AttributeError: module 'tensorflow' has no attribute 'random_normal'

Second error:
-- Original Code -------------------
train_batch_size = 32 #@param
noise_dimensions = 64 #@param
generator_lr = 0.001 #@param
discriminator_lr = 0.0002 #@param

def gen_opt():
gstep = tf.train.get_or_create_global_step()
base_lr = generator_lr

Halve the learning rate at 1000 steps.
lr = tf.cond(gstep < 1000, lambda: base_lr, lambda: base_lr / 2.0)
return tf.train.AdamOptimizer(lr, 0.5)

gan_estimator = tfgan.estimator.GANEstimator(
generator_fn=unconditional_generator,
discriminator_fn=unconditional_discriminator,
generator_loss_fn=tfgan.losses.wasserstein_generator_loss,
discriminator_loss_fn=tfgan.losses.wasserstein_discriminator_loss,
params={'batch_size': train_batch_size, 'noise_dims': noise_dimensions},
generator_optimizer=gen_opt,
discriminator_optimizer=tf.train.AdamOptimizer(discriminator_lr, 0.5),
get_eval_metric_ops_fn=get_eval_metric_ops_fn)
------------Code Error---------------------------------------------------------------
AttributeError Traceback (most recent call last)
in ()
18 params={'batch_size': train_batch_size, 'noise_dims': noise_dimensions},
19 generator_optimizer=gen_opt,
---> 20 discriminator_optimizer=tf.train.AdamOptimizer(discriminator_lr, 0.5),
21 get_eval_metric_ops_fn=get_eval_metric_ops_fn)

AttributeError: module 'tensorflow._api.v2.train' has no attribute 'AdamOptimizer'
Describe the expected behavior:
It seems this notebook was designed as of Tensorflow 1.X
but never upgraded to version 2.X
The web browser you are using (Chrome, Firefox, Safari, etc.):
Chrome
Link to self-contained notebook that reproduces this issue
(click the Share button, then Get Shareable Link):
https://colab.research.google.com/github/tensorflow/gan/blob/master/tensorflow_gan/examples/colab_notebooks/tfgan_tutorial.ipynb

Tutorial not working in Colab

Hi.
I've tried running the TF-GAN Tutorial in Colab, and it's not working.

Few errors (there are more...):

SyntaxError                               Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/autograph/pyct/parser.py in _attempt_to_parse_lambda_source(source, original_source, future_features, try_fallback)
    157   try:
--> 158     return parse(source, preamble_len=len(future_features)), source
    159 

30 frames
SyntaxError: invalid syntax (<unknown>, line 1)

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
ValueError: expected exactly one node node, found []

During handling of the above exception, another exception occurred:

UnsupportedLanguageElementError           Traceback (most recent call last)
UnsupportedLanguageElementError: could not parse the source code:

              .map(lambda _: tf.random_normal([bs, nd])))

This error may be avoided by creating the lambda in a standalone statement.


During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
<ipython-input-2-b8c4c89fd469> in <lambda>(_)
     12 
     13   noise_ds = (tf.data.Dataset.from_tensors(0).repeat()
---> 14               .map(lambda _: tf.random_normal([bs, nd])))
     15 
     16   if just_noise:

AttributeError: module 'tensorflow' has no attribute 'random_normal'

I run from this URL: https://colab.research.google.com/github/tensorflow/gan/blob/master/tensorflow_gan/examples/colab_notebooks/tfgan_tutorial.ipynb#scrollTo=zEhgLuGo8OGc
Modified runtime to GPU, and started running the cells.

Not working

I run this colab in https://colab.research.google.com/github/tensorflow/gan/blob/master/tensorflow_gan/examples/colab_notebooks/tfgan_tutorial.ipynb#scrollTo=83-azWpoYsDg&uniqifier=5&line=10
and found this error

AttributeError Traceback (most recent call last)
in ()
8 # Allow matplotlib images to render immediately.
9 get_ipython().magic('matplotlib inline')
---> 10 tf.logging.set_verbosity(tf.logging.ERROR) # Disable noisy outputs.

AttributeError: module 'tensorflow' has no attribute 'logging'

Memory leak in eval functions

System information

  • OS Platform and Distribution: Windows 10 / Google Colab
  • TensorFlow installed from binary: 2.1.0 - 2.2.0-rc3
  • Tensorflow-gan version: 2.0.0 and master

Describe the current behavior
Calling tfg.eval.inception_score and tfg.eval.frechet_inception_distance with a large number of images or successively with a low number of images will cause a crash due to an out-of-memory exception. Calling both with a single batch, once without consecutive calls, works.
This likely occurs with other functions as well but has only been tested with inception_score and frechet_inception_distance.

Describe the expected behavior
As long as a single batch fits into memory, consecutive calls to the function should als work. The functions should also work with a large number of input image, but a fitting value for num_batches where you know that a single batch will fit in memory.

Standalone code to reproduce the issue

import tensorflow_gan as tfg
import numpy as np

a = np.random.uniform(size=(100,32,32,3)).astype('float32')
tfg.eval.inception_score(a, num_batches=100)

OR

a = np.random.uniform(size=(100,32,32,3)).astype('float32')
for i in range(a.shape[0]):
  tfg.eval.inception_score(np.expand_dims(a[i],0), num_batches=1)

Colab link: https://colab.research.google.com/drive/1ob6in02YjUB7iCbhKnRvD5FPbWpxc1ar

Update to use keras?

Hi, this library doesn't seem to have a keras.Model. Keras is the main way many of us interact with TF, so it would be great to see here.

The TF docs have an example GAN class that works decently well:

https://www.tensorflow.org/guide/keras/customizing_what_happens_in_fit#wrapping_up_an_end-to-end_gan_example

But there's no official TF implementation committed anywhere. Would it be possible to add an official TF-GAN keras Model like the one in that example?

Being able to use Keras makes it much easier for people to learn and experiment with ML, so it would be awesome to see one here.

Thanks!

Wrong calculation of Inception score and FID for SAGAN without resizing

Hey and congratulations for this amazing library, I have been using it for our latest paper [paper], [code].

After the BREAKING CHANGE commit, the FID / Inception score is calculated wrongly for the SAGAN example. For ImageNet, it gives real inception score ~2.5.

After changing the sample_fn function defined here to perform the image resize, the correct FID and Inception scores are calculated.
I guess that is unexpected, since there is this comment, just in the above line:
# Image resizing happens inside the Inception SavedModel.

I managed to solve the problem by reshaping in the sample_fn function (as it was before the change), but I thought that it is worth bringing that to your attention :)

Let me know if you need any help!

Colab Tutorial Not TF 2.x Compatible

Even though the TF-Gan supports TF 2.x, the Google Colab tutorial is not TF 2.x compatible.

This should be updated to either lock the version to TF 1.x or update to support TF 2.x.

GAN models for generating HD images

Thanks a lot for this project! Is there any possibility to add some models which are designed for generating HD images i.e. StyleGAN (StyleGAN2, StyleGAN2-ADA)?

Thanks in advance!

Issue with tfgan_on_tpus.ipynb in the train step

NameError Traceback (most recent call last)
in init_global_real_logits()
42 try:
---> 43 real_logits is not None
44 except NameError:

NameError: name 'real_logits' is not defined

During handling of the above exception, another exception occurred:

AssertionError Traceback (most recent call last)
2 frames
in get_real_image_logits(num_images, classifier_model)
32 logits = sess.run(real_logits)
33 assert len(logits.shape) == 2
---> 34 assert logits.shape[0] == num_images
35 return logits
36

StartGAN drive download issue

File "/usr/lib/python3.8/contextlib.py", line 113, in enter
return next(self.gen)
File "/home/elich11/.local/lib/python3.8/site-packages/tensorflow_datasets/core/download/downloader.py", line 190, in _open_with_requests
url = _get_drive_url(url, session)
File "/home/elich11/.local/lib/python3.8/site-packages/tensorflow_datasets/core/download/downloader.py", line 208, in _get_drive_url
_assert_status(response)
File "/home/elich11/.local/lib/python3.8/site-packages/tensorflow_datasets/core/download/downloader.py", line 219, in _assert_status
raise DownloadError('Failed to get url {}. HTTP code: {}.'.format(
tensorflow_datasets.core.download.downloader.DownloadError: Failed to get url https://doc-14-84-docs.googleusercontent.com/docs/securesc/ha0ro937gcuc7l7deffksulhg5h7mbp1/fl65mfib6ml8n62jg64kj2uu4vp61259/1599668100000/13182073909007362810/*/0B7EVK8r0v71pd0FJY3Blby1HUTQ?e=download. HTTP code: 403.

Computation of Sliced Wasserstein Distance numerically unstable

The function _normalize_patches() defined and used here in tensorflow_gan.python.eval.sliced_wasserstein divides by the standard deviation of the values within a patch. To respect the case where the standard deviation is zero I suggest to add a small constant for numerical stability here:

patches = (patches - mean) / (tf.sqrt(variance) + 1.0e-12)

How to use input_fn for non tf data?

I found that the input_function accepts TF dataset and all the examples are being done from tfds dataset. I have hundreds of images scraped and want to have CGGAN for this. Can I have some guidance how to do using TFGAN?

How to use the Virtual Batch Normalization class?

I am currently trying the following using Kera's functional API:

from tensorflow_gan.python.features import VBN

inputs = Input(shape=(2))
layer1 = Dense(10, activation="relu")(inputs)
layer2 = VBN(layer1)(layer1)
output = Dense(1)(layer2)
model = Model(inputs=inputs, outputs=output)

But this results in the following error:

ValueError: The last dimension of the inputs to `Dense` should be defined. Found `None`.

Is this class compatible with the functional API or should I use it in a different way?

Set chech_for_unused_update_ops to False by default.

A bug is reported in SAGAN that check_for_unused_update_ops=True raise a ValueError. I find it suppose all ema buffers in bn to be unused update ops.

However there is no API in current SAGAN example to disable this check since it has ben encapsulated. So I set the kwarg in original tfgan implementation https://github.com/tensorflow/gan/blob/master/tensorflow_gan/python/train.py#L974 to False. The code runs normally then.

My tf version is 2.0.0 and tfgan is the current version.

Incompatibility with tensorflow 2.16

Hi,

I get AttributeError: module 'tensorflow' has no attribute 'estimator' when trying to import tensorflow_gan. I believe this is because the recent release of tensorflow (2.16) removed tf.estimator. Should then version 2.15 be a requirement to use tfgan ?
In addition tensorflow_probability should then be version 0.23

Thank you for looking at this :)

Performance issue in the definition of _sliced_wasserstein, tensorflow_gan/python/eval/sliced_wasserstein.py

Hello, I found a performance issue in the definition of _sliced_wasserstein, tensorflow_gan/python/eval/sliced_wasserstein.py, tf.shape(input=a)[1] will calculated repeatedly during the program execution, resulting in reduced efficiency. I think it should be created before the loop in the _sliced_wasserstein.

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

Pix2Pix?

Hello, hope you're staying safe and healthy! I believe back when gan used to be under tensorflow/models/research, it supported pix2pix directly. Was there a reason why it was removed? My group was reliant on it and I'm migrating our framework from TF1 to TF2, and we didn't catch this change.

However, I see in the legacy TF1 code that gan.pix2pix used slim.nets.cyclegan.cyclegan_generator_resnet and slim.nets.pix2pix.pix2pix_discriminator. If we want to reimplement the original that's compatible with TF2, would we use tensorflow_gan.examples.cyclegan.generator.cyclegan_generator_resnet and tensorflow_gan.examples.cyclegan.discriminator.pix2pix_discriminator as it is now, define the loss and optimizer as before in gan.pix2pix, and use tensorflow_gan.estimator.GANEstimator? I'm not sure what might no longer be supported.

But if you happen to have the previous implementation of pix2pix readily available and compatible with tensorflow_gan/TF2, that would be greatly appreciated :) Thanks!

Update the data provider for ImageNet 2012.

Since ImageNet changed its rule of downloading the dataset, I could not directly access the dataset via tfds.load. I followed URL to transform local ImageNet 2012 dataset to tfrecord files. However I find it seems to be incompatible with current tfds API, especially tfds.load as it in data_provider.py.

I am not sure if I should rewriter the data provider to fit the tfrecord files processed by URL since I am afraid the re-implementation may change the training behavior and lead to an unfair comparison or inexact reproduction.

BTW, what is the correct pipeline to reproduce SAGAN from ImageNet 2012 dataset on TPU? I think current one does not work due to the data provider. Should I download the dataset in tar files via imagennet_to_gcs.py in URL and set manual_dir to tfds.load to load it to google cloud storage and continue running data_provider.py, or re-implement the data provider to fit the results from processed tfrecords via URL?

It confused me since several official implementations from google conflict each other. The reproduction or comparison on ImageNet 2012 is quite expensive thus I start the issue rather than test it by meself.

Thx for any help!

Inception score evaluation throwing error

tensorflow 2.0
images are of shape: (28,28,1)
inception_score = tfgan.eval.inception_score(images)

error :
Shapes (2, 28, 28, 1) and [None, 299, 299, None] are incompatible

On all examples I get the error: " doesn't work when executing eagerly"

Using the latest tf (2.2) on ubunto 20.04 LTS

Here is the full log:

python3 progressive_gan/train_main.py --alsologtostderr
WARNING:tensorflow:From /home/elich11/.local/lib/python3.8/site-packages/tensorflow_gan/python/estimator/tpu_gan_estimator.py:42: The name tf.estimator.tpu.TPUEstimator is deprecated. Please use tf.compat.v1.estimator.tpu.TPUEstimator instead.

I0621 15:34:41.329408 139934777608000 train_main.py:156] dataset_file_pattern=
start_height=4
start_width=4
scale_base=2
num_resolutions=4
batch_size_schedule=[8, 8, 4]
kernel_size=3
colors=3
to_rgb_use_tanh_activation=False
stable_stage_num_images=1000
transition_stage_num_images=1000
total_num_images=10000
save_summaries_num_images=100
latent_vector_size=128
fmap_base=4096
fmap_decay=1.0
fmap_max=128
gradient_penalty_target=1.0
gradient_penalty_weight=10.0
real_score_penalty_weight=0.001
generator_learning_rate=0.001
discriminator_learning_rate=0.001
adam_beta1=0.0
adam_beta2=0.99
fake_grid_size=8
interp_grid_size=8
train_log_dir=/tmp/tfgan_logdir/progressive_gan/
master=
ps_replicas=0
task=0
2020-06-21 15:34:41.425124: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory
2020-06-21 15:34:41.434331: E tensorflow/stream_executor/cuda/cuda_driver.cc:313] failed call to cuInit: UNKNOWN ERROR (303)
2020-06-21 15:34:41.440051: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (DESKTOP-IB8RMFG): /proc/driver/nvidia/version does not exist
2020-06-21 15:34:41.443690: I tensorflow/core/platform/cpu_feature_guard.cc:143] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2020-06-21 15:34:41.477946: I tensorflow/core/platform/profile_utils/cpu_utils.cc:102] CPU Frequency: 2592000000 Hz
2020-06-21 15:34:41.485555: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x7f4444000b60 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-06-21 15:34:41.486501: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
I0621 15:34:41.505413 139934777608000 dataset_info.py:361] Load dataset info from /home/elich11/tensorflow_datasets/cifar10/3.0.2
I0621 15:34:41.520289 139934777608000 dataset_builder.py:282] Reusing dataset cifar10 (/home/elich11/tensorflow_datasets/cifar10/3.0.2)
I0621 15:34:41.521336 139934777608000 dataset_builder.py:477] Constructing tf.data.Dataset for split train, from /home/elich11/tensorflow_datasets/cifar10/3.0.2
2020-06-21 15:34:52.018620: W tensorflow/core/kernels/data/cache_dataset_ops.cc:794] The calling iterator did not fully read the dataset being cached. In order to avoid unexpected truncation of the dataset, the partially cached contents of the dataset will be discarded. This can happen if you have an input pipeline similar to dataset.cache().take(k).repeat(). You should use dataset.take(k).cache().repeat() instead.
2020-06-21 15:34:52.026975: W tensorflow/core/kernels/data/cache_dataset_ops.cc:794] The calling iterator did not fully read the dataset being cached. In order to avoid unexpected truncation of the dataset, the partially cached contents of the dataset will be discarded. This can happen if you have an input pipeline similar to dataset.cache().take(k).repeat(). You should use dataset.take(k).cache().repeat() instead.
Traceback (most recent call last):
File "progressive_gan/train_main.py", line 172, in
tf.app.run()
File "/home/elich11/.local/lib/python3.8/site-packages/tensorflow/python/platform/app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/home/elich11/.local/lib/python3.8/site-packages/absl/app.py", line 299, in run
_run_main(main, args)
File "/home/elich11/.local/lib/python3.8/site-packages/absl/app.py", line 250, in _run_main
sys.exit(main(argv))
File "progressive_gan/train_main.py", line 166, in main
model = train.build_model(stage_id, batch_size, real_images, **config)
File "/home/elich11/.local/lib/python3.8/site-packages/tensorflow_gan/examples/progressive_gan/train.py", line 348, in build_model
gan_model = tfgan.gan_model(
File "/home/elich11/.local/lib/python3.8/site-packages/tensorflow_gan/python/train.py", line 102, in gan_model
raise ValueError('tfgan.gan_model doesn't work when executing eagerly.')
ValueError: tfgan.gan_model doesn't work when executing eagerly.

Update losses module

This is in reference to issue #24. I was assigned to make the Tutorial Notebook compatible with Keras instead of the Estimator API.

I've already made a new input batch generator and Model Architectures using tfv2 functionalities. But I noticed that the losses module also uses certain tfv1 functionalities. For example, the losses_impl.py file uses tf.compat.v1.name_scope instead of tf.name_scope. I'd like to update the losses module to be tfv2 compatible.

I'm willing to contribute. Please assign this to me.

Getting error "`tfgan.gan_model` doesn't work when executing eagerly." on cifar example

On running python cifar/train.py I'm getting the following error:

`WARNING:tensorflow:From /home/arpit/Desktop/github_repos/gan/tensorflow_gan/python/estimator/tpu_gan_estimator.py:42: The name tf.estimator.tpu.TPUEstimator is deprecated. Please use tf.compat.v1.estimator.tpu.TPUEstimator instead.

2020-07-10 22:06:53.429745: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory
2020-07-10 22:06:53.429773: E tensorflow/stream_executor/cuda/cuda_driver.cc:313] failed call to cuInit: UNKNOWN ERROR (303)
2020-07-10 22:06:53.429788: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (arpit-Inspiron-5567): /proc/driver/nvidia/version does not exist
2020-07-10 22:06:53.430025: I tensorflow/core/platform/cpu_feature_guard.cc:143] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2020-07-10 22:06:53.456683: I tensorflow/core/platform/profile_utils/cpu_utils.cc:102] CPU Frequency: 2699905000 Hz
2020-07-10 22:06:53.456991: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x7fd6d0000b60 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-07-10 22:06:53.457020: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
I0710 22:06:53.459665 140562905868096 dataset_info.py:361] Load dataset info from /home/arpit/tensorflow_datasets/cifar10/3.0.2
I0710 22:06:53.461327 140562905868096 dataset_builder.py:282] Reusing dataset cifar10 (/home/arpit/tensorflow_datasets/cifar10/3.0.2)
I0710 22:06:53.461479 140562905868096 dataset_builder.py:477] Constructing tf.data.Dataset for split train, from /home/arpit/tensorflow_datasets/cifar10/3.0.2
2020-07-10 22:06:54.561262: W tensorflow/core/kernels/data/cache_dataset_ops.cc:794] The calling iterator did not fully read the dataset being cached. In order to avoid unexpected truncation of the dataset, the partially cached contents of the dataset will be discarded. This can happen if you have an input pipeline similar to dataset.cache().take(k).repeat(). You should use dataset.take(k).cache().repeat() instead.
2020-07-10 22:06:54.562604: W tensorflow/core/kernels/data/cache_dataset_ops.cc:794] The calling iterator did not fully read the dataset being cached. In order to avoid unexpected truncation of the dataset, the partially cached contents of the dataset will be discarded. This can happen if you have an input pipeline similar to dataset.cache().take(k).repeat(). You should use dataset.take(k).cache().repeat() instead.
Traceback (most recent call last):
File "cifar/train.py", line 61, in
app.run(main)
File "/home/arpit/Desktop/github_repos/gan/venv/lib/python3.8/site-packages/absl/app.py", line 299, in run
_run_main(main, args)
File "/home/arpit/Desktop/github_repos/gan/venv/lib/python3.8/site-packages/absl/app.py", line 250, in _run_main
sys.exit(main(argv))
File "cifar/train.py", line 56, in main
train_lib.train(hparams)
File "/home/arpit/Desktop/github_repos/gan/tensorflow_gan/examples/cifar/train_lib.py", line 62, in train
gan_model = tfgan.gan_model(
File "/home/arpit/Desktop/github_repos/gan/tensorflow_gan/python/train.py", line 102, in gan_model
raise ValueError('tfgan.gan_model doesn't work when executing eagerly.')
ValueError: tfgan.gan_model doesn't work when executing eagerly.
`

L1 loss problem with GAN if some data has ground-truth and some not

It's a great work.

If I want to use L1 loss between the generated image by generator and the ground-truth image, but some images have ground-truth and some others don't. That is to say, in a batch, some have ground-truth and some not. I only will use l1 loss with the images which have ground-truth.

In this problem, is there a way to address it?
Thank you!

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.