Generate Images
Estimator: TF-GAN's GANEstimator
Data: CIFAR dataset
Processor: Google Cloud TPU
Objective: To create a Generative Adverserial Network for generating fake images.
Use TFGAN's GANEstimator to generate fake images from CIFAR images
License: Apache License 2.0
Estimator: TF-GAN's GANEstimator
Data: CIFAR dataset
Processor: Google Cloud TPU
Objective: To create a Generative Adverserial Network for generating fake images.
dataset_dir = 'gs://{}/{}'.format(bucket, 'datasets')
def input_fn(mode, params):
assert 'batch_size' in params
assert 'noise_dims' in params
bs = params['batch_size']
nd = params['noise_dims']
split = 'train' if mode == tf.estimator.ModeKeys.TRAIN else 'test'
shuffle = (mode == tf.estimator.ModeKeys.TRAIN)
just_noise = (mode == tf.estimator.ModeKeys.PREDICT)
noise_ds = (tf.data.Dataset.from_tensors(0)
.map(lambda _: tf.random_normal([bs, nd]))
# If 'predict', just generate one batch.
.repeat(1 if just_noise else None))
if just_noise:
return noise_ds
def _preprocess(element):
# Map [0, 255] to [-1, 1].
images = (tf.cast(element['image'], tf.float32) - 127.5) / 127.5
return images
images_ds = (tfds.load('cifar10:3.*.*', split=split, data_dir=dataset_dir)
.map(_preprocess, num_parallel_calls=4)
.cache()
.repeat())
if shuffle:
images_ds = images_ds.shuffle(
buffer_size=10000, reshuffle_each_iteration=True)
images_ds = (images_ds.batch(bs, drop_remainder=True)
.prefetch(tf.data.experimental.AUTOTUNE))
return tf.data.Dataset.zip((noise_ds, images_ds))
InvalidArgumentError Traceback (most recent call last)
<ipython-input-16-0e87204247b4> in <module>()
1 params = {'batch_size': 1, 'noise_dims':1}
----> 2 input_fn(tf.estimator.ModeKeys.EVAL, params)
5 frames
<ipython-input-15-ec8f86310b3d> in input_fn(mode, params)
26 return images
27
---> 28 images_ds = (tfds.load('cifar10:3.*.*', split=split, data_dir=dataset_dir)
29 .map(_preprocess, num_parallel_calls=4)
30 .cache()
/usr/local/lib/python3.6/dist-packages/tensorflow_datasets/core/load.py in load(name, split, data_dir, batch_size, shuffle_files, download, as_supervised, decoders, read_config, with_info, builder_kwargs, download_and_prepare_kwargs, as_dataset_kwargs, try_gcs)
342 if download:
343 download_and_prepare_kwargs = download_and_prepare_kwargs or {}
--> 344 dbuilder.download_and_prepare(**download_and_prepare_kwargs)
345
346 if as_dataset_kwargs is None:
/usr/local/lib/python3.6/dist-packages/tensorflow_datasets/core/dataset_builder.py in download_and_prepare(self, download_dir, download_config)
370 dl_manager = self._make_download_manager(
371 download_dir=download_dir,
--> 372 download_config=download_config)
373
374 # Create a tmp dir and rename to self._data_dir on successful exit.
/usr/local/lib/python3.6/dist-packages/tensorflow_datasets/core/dataset_builder.py in _make_download_manager(self, download_dir, download_config)
796 force_extraction=(download_config.download_mode == FORCE_REDOWNLOAD),
797 force_checksums_validation=download_config.force_checksums_validation,
--> 798 register_checksums=download_config.register_checksums,
799 )
800
/usr/local/lib/python3.6/dist-packages/tensorflow_datasets/core/download/download_manager.py in __init__(self, download_dir, extract_dir, manual_dir, manual_dir_instructions, url_infos, dataset_name, force_download, force_extraction, force_checksums_validation, register_checksums)
201 self._manual_dir = manual_dir and os.path.expanduser(manual_dir)
202 self._manual_dir_instructions = manual_dir_instructions
--> 203 tf.io.gfile.makedirs(self._download_dir)
204 tf.io.gfile.makedirs(self._extract_dir)
205 self._force_download = force_download
/usr/local/lib/python3.6/dist-packages/tensorflow/python/lib/io/file_io.py in recursive_create_dir_v2(path)
481 errors.OpError: If the operation fails.
482 """
--> 483 _pywrap_file_io.RecursivelyCreateDir(compat.path_to_bytes(path))
484
485
InvalidArgumentError: 'object' must be a non-empty string. (File: gs://likarajo_bucket/)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.