title: Invalid first argument Error when fitting Keras model in R Markdown
body: <p>After following keras tutorial on functional API, I'm trying merging 2 Neural Networks, however, I keep getting this error:</p>
  <pre><code>Error in dim(x) &lt;- length(x) : 
  invalid first argument, must be vector (list or atomic)
  </code></pre>
  <p>this is the code:</p>
  <p>Note:  x_train is a <code>tibble</code> and train_gen is <code>flow_images_from_directory</code> object.</p>
  <pre><code>input_img &lt;- layer_input(shape = c(140,140,3) , name = &quot;image&quot;)
  input_tab &lt;- layer_input(shape = c(ncol(x_train)) , name = &quot;tabular&quot;)
  
  
  cnn &lt;- input_img %&gt;% 
    layer_conv_2d(32, kernel_size = c(3,3) , padding = &quot;same&quot; , 
                  activation = &quot;relu&quot;) %&gt;% 
    layer_max_pooling_2d(pool_size = c(2,2)) %&gt;% 
    layer_conv_2d(64 , kernel_size = c(3,3) , activation = &quot;relu&quot;) %&gt;%
    layer_max_pooling_2d(pool_size = c(2,2)) %&gt;% 
    layer_flatten() %&gt;% 
    layer_dropout(0.5)
    
  
  nn &lt;- input_tab %&gt;% 
    layer_dense(128) %&gt;% 
    layer_activation(&quot;relu&quot;) %&gt;% 
    layer_dense(64) %&gt;% 
    layer_activation(&quot;relu&quot;) %&gt;% 
    layer_dense(32) %&gt;% 
    layer_activation(&quot;relu&quot;) %&gt;% 
    layer_dense(16) %&gt;% 
    layer_activation(&quot;relu&quot;)
  
  output &lt;- layer_concatenate(c(cnn , nn)) %&gt;% 
    layer_dense(16) %&gt;% 
    layer_activation(&quot;relu&quot;) %&gt;% 
    layer_dense(6) %&gt;% 
    layer_activation(&quot;sigmoid&quot;)
  
  model &lt;- keras_model(inputs = c(input_img  ,  input_tab) ,
                       outputs = output) %&gt;% 
    compile(loss = &quot;categorical_crossentropy&quot; , optimizer = optimizer_adam() ,
            metrics = &quot;accuracy&quot;)
  
  callbacks &lt;- callback_early_stopping(monitor = &quot;val_loss&quot; , patience = 5)
  
  final_history &lt;- model %&gt;% fit(
    x = list(train_gen , x_train),
    y = list(train_gen$classes , x_train),
    epochs = 50 ,
    callbacks = callbacks,
    validation_split = 0.2)
  
  Error in dim(x) &lt;- length(x) : 
  invalid first argument, must be vector (list or atomic)
  </code></pre>
  <p>After long searching online i could not find any help on this.</p>
  <p><strong>why this error is produced?</strong></p>