class_docstr: Wide and deep model, implemented using TFLearn
docstr: Model - wide and deep - built using tflearn
docstr_tok: ["Model","-","wide","and","deep","-","built","using","tflearn"]
code: def build_model(self, learning_rate=[0.001, 0.01]):
      """
      Model - wide and deep - built using tflearn
      """
      n_cc = len(self.continuous_columns)
      n_categories = 1  # two categories: is_idv and is_not_idv
      input_shape = [None, n_cc]
      if self.verbose:
          print(
              "=" * 77
              + " Model %s (type=%s)" % (self.name, self.model_type)
          )
          print("  Input placeholder shape=%s" % str(input_shape))
      wide_inputs = tflearn.input_data(shape=input_shape, name="wide_X")
      if not isinstance(learning_rate, list):
          learning_rate = [learning_rate, learning_rate]  # wide, deep
      if self.verbose:
          print("  Learning rates (wide, deep)=%s" % learning_rate)
  
      with tf.name_scope(
          "Y"
      ):  # placeholder for target variable (i.e. trainY input)
          Y_in = tf.placeholder(
              shape=[None, 1], dtype=tf.float32, name="Y"
          )
  
      with tf.variable_scope(None, "cb_unit", [wide_inputs]) as scope:
          central_bias = tflearn.variables.variable(
              "central_bias",
              shape=[1],
              initializer=tf.constant_initializer(np.random.randn()),
              trainable=True,
              restore=True,
          )
          tf.add_to_collection(
              tf.GraphKeys.LAYER_VARIABLES + "/cb_unit", central_bias
          )
  
      if "wide" in self.model_type:
          wide_network = self.wide_model(wide_inputs, n_cc)
          network = wide_network
          wide_network_with_bias = tf.add(
              wide_network, central_bias, name="wide_with_bias"
          )
  
      if "deep" in self.model_type:
          deep_network = self.deep_model(wide_inputs, n_cc)
          deep_network_with_bias = tf.add(
              deep_network, central_bias, name="deep_with_bias"
          )
          if "wide" in self.model_type:
              network = tf.add(wide_network, deep_network)
              if self.verbose:
                  print("Wide + deep model network %s" % network)
          else:
              network = deep_network
  
      network = tf.add(network, central_bias, name="add_central_bias")
  
      # add validation monitor summaries giving confusion matrix entries
      with tf.name_scope("Monitors"):
          predictions = tf.cast(tf.greater(network, 0), tf.int64)
          print("predictions=%s" % predictions)
          Ybool = tf.cast(Y_in, tf.bool)
          print("Ybool=%s" % Ybool)
          pos = tf.boolean_mask(predictions, Ybool)
          neg = tf.boolean_mask(predictions, ~Ybool)
          psize = tf.cast(tf.shape(pos)[0], tf.int64)
          nsize = tf.cast(tf.shape(neg)[0], tf.int64)
          true_positive = tf.reduce_sum(pos, name="true_positive")
          false_negative = tf.subtract(
              psize, true_positive, name="false_negative"
          )
          false_positive = tf.reduce_sum(neg, name="false_positive")
          true_negative = tf.subtract(
              nsize, false_positive, name="true_negative"
          )
          overall_accuracy = tf.truediv(
              tf.add(true_positive, true_negative),
              tf.add(nsize, psize),
              name="overall_accuracy",
          )
      vmset = [
          true_positive,
          true_negative,
          false_positive,
          false_negative,
          overall_accuracy,
      ]
  
      trainable_vars = tf.trainable_variables()
      tv_deep = [
          v for v in trainable_vars if v.name.startswith("deep_")
      ]
      tv_wide = [
          v for v in trainable_vars if v.name.startswith("wide_")
      ]
  
      if self.verbose:
          print("DEEP trainable_vars")
          for v in tv_deep:
              print("  Variable %s: %s" % (v.name, v))
          print("WIDE trainable_vars")
          for v in tv_wide:
              print("  Variable %s: %s" % (v.name, v))
  
      if "wide" in self.model_type:
          if not "deep" in self.model_type:
              tv_wide.append(central_bias)
          tflearn.regression(
              wide_network_with_bias,
              placeholder=Y_in,
              optimizer="sgd",
              # loss='roc_auc_score',
              loss="binary_crossentropy",
              metric="accuracy",
              learning_rate=learning_rate[0],
              validation_monitors=vmset,
              trainable_vars=tv_wide,
              op_name="wide_regression",
              name="Y",
          )
  
      if "deep" in self.model_type:
          if not "wide" in self.model_type:
              tv_wide.append(central_bias)
          tflearn.regression(
              deep_network_with_bias,
              placeholder=Y_in,
              optimizer="adam",
              # loss='roc_auc_score',
              loss="binary_crossentropy",
              metric="accuracy",
              learning_rate=learning_rate[1],
              validation_monitors=vmset
              if not "wide" in self.model_type
              else None,
              trainable_vars=tv_deep,
              op_name="deep_regression",
              name="Y",
          )
  
      if (
          self.model_type == "wide+deep"
      ):  # learn central bias separately for wide+deep
          tflearn.regression(
              network,
              placeholder=Y_in,
              optimizer="adam",
              loss="binary_crossentropy",
              metric="accuracy",
              learning_rate=learning_rate[0],  # use wide learning rate
              trainable_vars=[central_bias],
              op_name="central_bias_regression",
              name="Y",
          )
  
      self.model = tflearn.DNN(
          network,
          tensorboard_verbose=self.tensorboard_verbose,
          max_checkpoints=5,
          checkpoint_path="%s/%s.tfl"
          % (self.checkpoints_dir, self.name),
      )
  
      if self.verbose:
          print("Target variables:")
          for v in tf.get_collection(tf.GraphKeys.TARGETS):
              print("  variable %s: %s" % (v.name, v))
  
          print("=" * 77)
  
imports: from __future__ import division, print_function
  import os
  import sys
  import argparse
  import tflearn
  import tempfile
  import urllib
  import numpy
  import pandas
  import tensorflow.compat.v1
label_desc: Use image node_id 3 for calling the TFLearnWideAndDeep obj's underlying member method code with example usage: obj.build_model(learning_rate) without return types