Git Product home page Git Product logo

Comments (2)

a7b23 avatar a7b23 commented on May 6, 2024

+1

from compare_gan.

ilyakava avatar ilyakava commented on May 6, 2024

Happening on python 3.6.9 and tf 1.15.0. For some reason any dataset appears as empty.

What worked for me to avoid this error is replacing the train_input_fn here with:

  def train_input_fn(self, params=None, preprocess_fn=None):
    """Input function for reading data.

    Args:
      params: Python dictionary with parameters. Must contain the key
        "batch_size". TPUEstimator will set this for you!
      preprocess_fn: Function to process single examples. This is allowed to
        have a `seed` argument.

    Returns:
      `tf.data.Dataset` with preprocessed and batched examples.
    """
    if params is None:
      params = {}
    seed = self._get_per_host_random_seed(params.get("context", None))
    logging.info("train_input_fn(): params=%s seed=%s", params, seed)

    ds = self._load_dataset(split=self._train_split)
    # ds = ds.filter(self._train_filter_fn)
    ds = ds.repeat()
    def one_function(image, label):
      images, labels = self._train_transform_fn(image, label, seed=seed)
      features = {
          "images": images,
          "z": np.random.randn(120).astype(np.float32),
      }
      features["sampled_labels"] = labels
      
      return features, labels
    ds = ds.map(one_function)
      
    # ds = ds.map(functools.partial(self._train_transform_fn, seed=seed))
    # if preprocess_fn is not None:
      # if "seed" in inspect.getargspec(preprocess_fn).args:
      #   preprocess_fn = functools.partial(preprocess_fn, seed=seed)
      # ds = ds.map(one_function)
      # Add a feature for the random offset of operations in tpu_random.py.
    ds = tpu_random.add_random_offset_to_features(ds)
    # ds = ds.shuffle(FLAGS.data_shuffle_buffer_size, seed=seed)
    if "batch_size" in params:
      ds = ds.batch(params["batch_size"], drop_remainder=True)
    return ds.prefetch(tf.contrib.data.AUTOTUNE)

from compare_gan.

Related Issues (20)

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.