class_docstr: A set of predefined models to approximate Q or log of pi (policy).
  
  The loss function needs to be 'cross_entropy_with_softmax' for policy
  gradient methods.
docstr: Feedforward network to approximate Q or log of pi.
  
  Args:
      shape_of_inputs: tuple of array (input) dimensions.
      number_of_outputs: dimension of output, equals the number of
          possible actions.
      model_hidden_layers: string representing a list of integers
          corresponding to number of nodes in each hidden layer.
      loss_function: if not specified, use squared loss by default.
      use_placeholder_for_input: if true, inputs have to be replaced
          later with actual input_variable.
  
  Returns: a Python dictionary with string valued keys including
      'inputs', 'outputs', 'loss' and 'f'.
docstr_tok: ["Feedforward","network","to","approximate","Q","or","log","of","pi",".","Args",":","shape_of_inputs",":","tuple","of","array","(","input",")","dimensions",".","number_of_outputs",":","dimension","of","output",",","equals","the","number","of","possible","actions",".","model_hidden_layers",":","string","representing","a","list","of","integers","corresponding","to","number","of","nodes","in","each","hidden","layer",".","loss_function",":","if","not","specified",",","use","squared","loss","by","default",".","use_placeholder_for_input",":","if","true",",","inputs","have","to","be","replaced","later","with","actual","input_variable",".","Returns",":","a","Python","dictionary","with","string","valued","keys","including","'inputs","'",",","'outputs","'",",","'loss","'","and","'","f","'","."]
code: def feedforward_network(
      shape_of_inputs,
      number_of_outputs,
      model_hidden_layers,
      loss_function=None,
      use_placeholder_for_input=False,
  ):
      """Feedforward network to approximate Q or log of pi.
  
      Args:
          shape_of_inputs: tuple of array (input) dimensions.
          number_of_outputs: dimension of output, equals the number of
              possible actions.
          model_hidden_layers: string representing a list of integers
              corresponding to number of nodes in each hidden layer.
          loss_function: if not specified, use squared loss by default.
          use_placeholder_for_input: if true, inputs have to be replaced
              later with actual input_variable.
  
      Returns: a Python dictionary with string valued keys including
          'inputs', 'outputs', 'loss' and 'f'.
      """
      # input/output
      inputs = (
          C.ops.placeholder(shape=shape_of_inputs)
          if use_placeholder_for_input
          else C.ops.input_variable(
              shape=shape_of_inputs, dtype=np.float32
          )
      )
      outputs = C.ops.input_variable(
          shape=(number_of_outputs,), dtype=np.float32
      )
  
      # network structure
      hidden_layers = ast.literal_eval(model_hidden_layers)
      f = C.layers.Sequential(
          [
              C.layers.For(
                  range(len(hidden_layers)),
                  lambda h: C.layers.Dense(
                      hidden_layers[h], activation=C.ops.relu
                  ),
              ),
              C.layers.Dense(number_of_outputs, activation=None),
          ]
      )(inputs)
  
      if loss_function is None:
          loss = C.losses.squared_error(f, outputs)
      else:
          loss = loss_function(f, outputs)
  
      return {
          "inputs": inputs,
          "outputs": outputs,
          "f": f,
          "loss": loss,
      }
  
file_path: CNTK/bindings/python/cntk/contrib/deeprl/agent/shared/models.py
imports: import cntk
  import numpy
  import ast
label_desc: Use image node_id 1 for calling the Models obj's underlying member method code with example usage: obj.feedforward_network(shape_of_inputs, number_of_outputs, model_hidden_layers, loss_function, use_placeholder_for_input) and returns: dict