How to use the census.tf-keras.trainer.model.create_keras_model function in census

To help you get started, we’ve selected a few census examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GoogleCloudPlatform / cloudml-samples / census / tf-keras / trainer / task.py View on Github external
Uses the Keras model defined in model.py and trains on data loaded and
  preprocessed in util.py. Saves the trained model in TensorFlow SavedModel
  format to the path defined in part by the --job-dir argument.

  Args:
    args: dictionary of arguments - see get_args() for details
  """

  train_x, train_y, eval_x, eval_y = util.load_data()

  # dimensions
  num_train_examples, input_dim = train_x.shape
  num_eval_examples = eval_x.shape[0]

  # Create the Keras Model
  keras_model = model.create_keras_model(
      input_dim=input_dim, learning_rate=args.learning_rate)

  # Pass a numpy array by passing DataFrame.values
  training_dataset = model.input_fn(
      features=train_x.values,
      labels=train_y,
      shuffle=True,
      num_epochs=args.num_epochs,
      batch_size=args.batch_size)

  # Pass a numpy array by passing DataFrame.values
  validation_dataset = model.input_fn(
      features=eval_x.values,
      labels=eval_y,
      shuffle=False,
      num_epochs=args.num_epochs,