title: Duplicate/Replicate tensorflow layers with same properties to form a graph
body: <p>The task I try to implement by using a neural network differs a bit from its most common usage. I try to simulate a physical process by propagating something from the input to the output layer by optimizing the network's weights which represents physical properties.</p>
  
  <p>Therefor I need a i.e. 150 layer network where each layer has the same properties in the form </p>
  
  <blockquote>
    <p>mx+b</p>
  </blockquote>
  
  <p>where x is my variable I like to optimize and m an external factor which is the same for each layer (b is not in use right now).</p>
  
  <p>I would like to automate the process of creating the graph rather than copy/paste each layer. So is there a function to copy the structure of the first layer to all following layers? </p>
  
  <p>In tensorflow it should look like something like this here:</p>
  
  <pre><code>graph = tf.Graph()
  with graph.as_default():
  
      # Input data.
      tf_input = tf.placeholder(tf.float32, shape=(n_data, n))
      tf_spatial_grid = tf.constant(m_index_mat)
      tf_ph_unit = tf.const(m_unit_mat)
      tf_output = tf.placeholder(tf.float32, shape=(n_data, n))
  
      # new hidden layer 1    
      hidden_weights = tf.Variable( tf.truncated_normal([n*n, 1]) )
      hidden_layer = tf.nn.matmul( tf.matmul( tf_input, hidden_weights), tf_ph_unit)
  
      # new hidden layer 2
      hidden_weights_2 = tf.Variable( tf.truncated_normal([n*n, 1]) )
      hidden_layer_2 = tf.nn.matmul( tf.matmul( hidden_layer, hidden_weights_2), tf_ph_unit)
  </code></pre>
  
  <p>......</p>
  
  <pre><code>    # new hidden layer n
      hidden_weights_n = tf.Variable( tf.truncated_normal([n*n, 1]) )
      hidden_layer_n = tf.nn.matmul( tf.matmul( hidden_layer_m, hidden_weights_n), tf_ph_unit)
  </code></pre>
  
  <p>...</p>
  
  <p>So is there any option that automates this process somehow? Maybe I'm missing something</p>
  
  <p>I really appreciate any help!</p>