title: INVALID_ARGUMENT: TypeError: `generator` yielded an element of shape (0,) where an element of shape (None, None, None, None) was expected
body: <p>I got a huge training dataset to train a neural network. Due to this, I am using the generator-based approach. My generator class code looks like below</p>
  <pre class="lang-py prettyprint-override"><code>class My_Custom_Generator(tf.keras.utils.Sequence) :
    
    def __init__(self, videos, batch_size) :
      # does some object init operations
      
      
    def __len__(self) :
      # returns number of batches possible for the given batch size
    
    
    def __getitem__(self, idx) :
  
      # batch_x = [nparray_feature_a, nparray_feature_b, nparray_feature_c]
      # batch_y = nparray_y
      # returns batch_x, batch_y
  </code></pre>
  <p>I am training the model as below</p>
  <pre class="lang-sh prettyprint-override"><code>epochs = 150
  callbacks_list=[ModelCheckpoint(save_best_only=True,filepath=checkpoint_path)]
  history = a.fit(generator_object,steps_per_epoch=200,
                                    epochs=epochs,
                                    callbacks = callbacks_list)
  </code></pre>
  <p>However, I am getting this error as shown below</p>
  <pre><code>Epoch 1/150
  ---------------------------------------------------------------------------
  InvalidArgumentError                      Traceback (most recent call last)
  &lt;ipython-input-110-7bd7f976bede&gt; in &lt;module&gt;()
        6                                   validation_data=tg,
        7                                   validation_steps=1,
  ----&gt; 8                                   callbacks = callbacks_list )
  
  1 frames
  /usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/execute.py in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name)
       57     ctx.ensure_initialized()
       58     tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
  ---&gt; 59                                         inputs, attrs, num_outputs)
       60   except core._NotOkStatusException as e:
       61     if name is not None:
  
  InvalidArgumentError: 2 root error(s) found.
    (0) INVALID_ARGUMENT:  TypeError: `generator` yielded an element of shape (0,) where an element of shape (None, None, None, None) was expected.
  Traceback (most recent call last):
  
    File &quot;/usr/local/lib/python3.7/dist-packages/tensorflow/python/ops/script_ops.py&quot;, line 275, in __call__
      ret = func(*args)
  
    File &quot;/usr/local/lib/python3.7/dist-packages/tensorflow/python/autograph/impl/api.py&quot;, line 649, in wrapper
      return func(*args, **kwargs)
  
    File &quot;/usr/local/lib/python3.7/dist-packages/tensorflow/python/data/ops/dataset_ops.py&quot;, line 1036, in generator_py_func
      f&quot;`generator` yielded an element of shape {ret_array.shape} &quot;
  
  TypeError: `generator` yielded an element of shape (0,) where an element of shape (None, None, None, None) was expected.
  
  
       [[{{node PyFunc}}]]
       [[IteratorGetNext]]
       [[IteratorGetNext/_8]]
    (1) INVALID_ARGUMENT:  TypeError: `generator` yielded an element of shape (0,) where an element of shape (None, None, None, None) was expected.
  Traceback (most recent call last):
  
    File &quot;/usr/local/lib/python3.7/dist-packages/tensorflow/python/ops/script_ops.py&quot;, line 275, in __call__
      ret = func(*args)
  
    File &quot;/usr/local/lib/python3.7/dist-packages/tensorflow/python/autograph/impl/api.py&quot;, line 649, in wrapper
      return func(*args, **kwargs)
  
    File &quot;/usr/local/lib/python3.7/dist-packages/tensorflow/python/data/ops/dataset_ops.py&quot;, line 1036, in generator_py_func
      f&quot;`generator` yielded an element of shape {ret_array.shape} &quot;
  
  TypeError: `generator` yielded an element of shape (0,) where an element of shape (None, None, None, None) was expected.
  
  
       [[{{node PyFunc}}]]
       [[IteratorGetNext]]
  0 successful operations.
  0 derived errors ignored. [Op:__inference_train_function_34754]
  
  Function call stack:
  train_function -&gt; train_function
  </code></pre>
  <p>Also to note, my deep neural architecture takes input as a concatenation of three features (Xs).</p>
  <p>What is possibly going wrong here, please let me know if you need more information.</p>