SHARE
TWEET

Untitled

a guest Jul 19th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def build_subnetwork(self,
  2.                          features,
  3.                          logits_dimension,
  4.                          training,
  5.                          iteration_step,
  6.                          summary,
  7.                          previous_ensemble=None):
  8.         input_layer = tf.to_float(features[FEATURES_KEY])
  9.         kernel_initializer = tf.glorot_uniform_initializer(seed=self._seed)
  10.         last_layer = input_layer
  11.         for _ in range(self._num_layers):
  12.             last_layer = tf.layers.dense(
  13.                 last_layer,
  14.                 units=self._layer_size,
  15.                 activation=tf.nn.relu,
  16.                 kernel_initializer=kernel_initializer)
  17.         logits = tf.layers.dense(
  18.             last_layer,
  19.             units=logits_dimension,
  20.             kernel_initializer=kernel_initializer)
  21.         persisted_tensors = {_NUM_LAYERS_KEY: tf.constant(self._num_layers)}
  22.         return adanet.Subnetwork(
  23.             last_layer=last_layer,
  24.             logits=logits,
  25.             complexity=self._measure_complexity(),
  26.             persisted_tensors=persisted_tensors)
  27.      
  28. def build_subnetwork(self,
  29.                          features,
  30.                          logits_dimension,
  31.                          training,
  32.                          iteration_step,
  33.                          summary,
  34.                          previous_ensemble=None):
  35.         input_layer = tf.to_float(features[FEATURES_KEY])
  36.         kernel_initializer = tf.glorot_uniform_initializer(seed=self._seed)
  37.         last_layer = input_layer
  38.         for _ in range(self._num_layers):
  39.             last_layer = tf.keras.layers.Dense(
  40.                 units=64, activation="relu", kernel_initializer=kernel_initializer,
  41.                 use_bias=True, bias_initializer=kernel_initializer)(last_layer)
  42.         logits = tf.keras.layers.Dense(
  43.             units=2, activation=None, kernel_initializer=kernel_initializer,
  44.             use_bias=True, bias_initializer=kernel_initializer)(last_layer)
  45.         persisted_tensors = {_NUM_LAYERS_KEY: tf.constant(self._num_layers)}
  46.         return adanet.Subnetwork(
  47.             last_layer=last_layer,
  48.             logits=logits,
  49.             complexity=self._measure_complexity(),
  50.             persisted_tensors=persisted_tensors)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top