title: TypeError: 'int' object is not iterable while training a neural network
body: <p>I am trying to train NeRF (<a href="https://github.com/bmild/nerf" rel="nofollow noreferrer">https://github.com/bmild/nerf</a>), below is the error I am getting. I have tried to print the datatype of the of the variables. I do not know how to proceed next.</p>
  <p>Here is a code snippet:</p>
  <p>In run_nerf_helpers.py:</p>
  <pre><code>def init_nerf_model(D=8, W=256, input_ch=3, input_ch_views=3, output_ch=4, skips=[4], use_viewdirs=False):
  
      relu = tf.keras.layers.ReLU()
      def dense(W, act=relu): return tf.keras.layers.Dense(W, activation=act)
  
      print('MODEL', input_ch, input_ch_views, type(
          input_ch), type(input_ch_views), use_viewdirs)
      input_ch = int(input_ch)
      input_ch_views = int(input_ch_views)
  
      inputs = tf.keras.Input(shape=(input_ch + input_ch_views))
      inputs_pts, inputs_views = tf.split(inputs, [input_ch, input_ch_views], -1)
      inputs_pts.set_shape([None, input_ch])
      inputs_views.set_shape([None, input_ch_views])
  
      print(inputs.shape, inputs_pts.shape, inputs_views.shape)
      outputs = inputs_pts
      for i in range(D):
          outputs = dense(W)(outputs)
          if i in skips:
              outputs = tf.concat([inputs_pts, outputs], -1)
  </code></pre>
  <p>In run_nerf.py</p>
  <pre><code>def create_nerf(args):
      &quot;&quot;&quot;Instantiate NeRF's MLP model.&quot;&quot;&quot;
  
      embed_fn, input_ch = get_embedder(args.multires, args.i_embed)
  
      input_ch_views = 0
      embeddirs_fn = None
      if args.use_viewdirs:
          embeddirs_fn, input_ch_views = get_embedder(
              args.multires_views, args.i_embed)
      output_ch = 4
      skips = [4]
      model = init_nerf_model(
          D=args.netdepth, W=args.netwidth,
          input_ch=input_ch, output_ch=output_ch, skips=skips,
          input_ch_views=input_ch_views, use_viewdirs=args.use_viewdirs)
      grad_vars = model.trainable_variables
      models = {'model': model}
  
  def create_nerf(args):
      &quot;&quot;&quot;Instantiate NeRF's MLP model.&quot;&quot;&quot;
  
      embed_fn, input_ch = get_embedder(args.multires, args.i_embed)
  
      input_ch_views = 0
      embeddirs_fn = None
      if args.use_viewdirs:
          embeddirs_fn, input_ch_views = get_embedder(
              args.multires_views, args.i_embed)
      output_ch = 4
      skips = [4]
      model = init_nerf_model(
          D=args.netdepth, W=args.netwidth,
          input_ch=input_ch, output_ch=output_ch, skips=skips,
          input_ch_views=input_ch_views, use_viewdirs=args.use_viewdirs)
      grad_vars = model.trainable_variables
      models = {'model': model}
  </code></pre>
  <p>Error:</p>
  <pre><code>('input_ch_views:', &lt;type 'int'&gt;)
  ('output_ch:', &lt;type 'int'&gt;)
  ('use_viewdirs:', &lt;type 'bool'&gt;)
  ('MODEL', 63, 27, &lt;type 'int'&gt;, &lt;type 'int'&gt;, True)
  
  Traceback (most recent call last):
    File &quot;run_nerf.py&quot;, line 938, in &lt;module&gt;
      train()
    File &quot;run_nerf.py&quot;, line 682, in train
      args)
    File &quot;run_nerf.py&quot;, line 397, in create_nerf
      input_ch_views=input_ch_views, use_viewdirs=args.use_viewdirs)
    File &quot;/home/nerf-master/run_nerf_helpers.py&quot;, line 90, in init_nerf_model
      inputs = tf.keras.Input(shape=(input_ch + input_ch_views))
    File &quot;/usr/local/lib/python2.7/dist-packages/tensorflow/python/keras/engine/input_layer.py&quot;, line 231, in Input
      input_tensor=tensor)
    File &quot;/usr/local/lib/python2.7/dist-packages/tensorflow/python/keras/engine/input_layer.py&quot;, line 91, in __init__
      batch_input_shape = (batch_size,) + tuple(input_shape)
  TypeError: 'int' object is not iterable
  </code></pre>
  <p>I am new at this. Any help would be really appreciated. Thank you :)</p>