class_docstr: A simple DNN subnetwork builder.
class_docstr_tok: ["A","simple","DNN","subnetwork","builder","."]
code: def build_subnetwork(
      self,
      features,
      logits_dimension,
      training,
      iteration_step,
      summary,
      previous_ensemble=None,
  ):
      seed = self._seed
      if previous_ensemble:
          # Increment seed so different iterations don't learn the exact same thing.
          seed += 1
      with tf.compat.v1.variable_scope("dnn"):
          persisted_tensors = {}
          with tf.compat.v1.variable_scope("hidden_layer"):
              if self._feature_columns:
                  input_layer = tf.compat.v1.feature_column.input_layer(
                      features=features,
                      feature_columns=self._feature_columns,
                  )
              else:
                  input_layer = features["x"]
              w = tf.compat.v1.get_variable(
                  shape=[input_layer.shape[1], self._layer_size],
                  initializer=tf.compat.v1.glorot_uniform_initializer(
                      seed=seed
                  ),
                  name="weight",
              )
              hidden_layer = tf.matmul(input_layer, w)
  
          if previous_ensemble:
              other_hidden_layer = (
                  previous_ensemble.weighted_subnetworks[
                      -1
                  ].subnetwork.persisted_tensors["hidden_layer"]
              )
              hidden_layer = tf.concat(
                  [hidden_layer, other_hidden_layer], axis=1
              )
  
          # Use a leaky-relu activation so that gradients can flow even when
          # outputs are negative. Leaky relu has a non-zero slope when x < 0.
          # Otherwise success at learning is completely dependent on random seed.
          hidden_layer = tf.nn.leaky_relu(hidden_layer, alpha=0.2)
          persisted_tensors["hidden_layer"] = hidden_layer
          if training:
              # This change will only be in the next iteration if
              # `freeze_training_graph` is `True`.
              persisted_tensors["hidden_layer"] = 2 * hidden_layer
  
      with tf.compat.v1.variable_scope("logits"):
          logits = tf.compat.v1.layers.dense(
              hidden_layer,
              logits_dimension,
              kernel_initializer=tf.compat.v1.glorot_uniform_initializer(
                  seed=seed
              ),
          )
  
      summary.scalar("scalar", 3)
      summary.image("image", tf.ones([1, 3, 3, 1]))
      with tf.compat.v1.variable_scope("nested"):
          summary.scalar("scalar", 5)
  
      return Subnetwork(
          last_layer=logits,
          logits=logits,
          complexity=3,
          persisted_tensors=persisted_tensors,
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import itertools
  import json
  import os
  from absl.testing import parameterized
  from adanet import tf_compat
  from adanet.core import testing_utils
  from adanet.core.tpu_estimator import TPUEstimator
  from adanet.subnetwork import Builder
  from adanet.subnetwork import Report
  from adanet.subnetwork import SimpleGenerator
  from adanet.subnetwork import Subnetwork
  import numpy
  import tensorflow.compat.v2
  from tensorflow_estimator.python.estimator.head import regression_head
label_desc: Use image node_id 3 for calling the _DNNBuilder obj's underlying member method code with example usage: obj.build_subnetwork(features, logits_dimension, training, iteration_step, summary, previous_ensemble) and returns: Subnetwork