votes up 6

Please provide as model inputs either a single array or a list of arrays. You passed: (param1)=(param1)

Package:
keras
github stars 52268
Exception Class:
ValueError

Raise code

      'Please provide as model inputs either a single array or a list of '
          'arrays. You passed: {}={}'.format(field_name, str(orig_inp)))
  elif isinstance(inp, dict):
    if not allow_dict:
      raise ValueError(
          'You cannot pass a dictionary as model {}.'.format(field_name))
  elif not isinstance(inp, np.ndarray) and not tf.is_tensor(inp):
    raise ValueError(
        'Please provide as model inputs either a single array or a list of '
        'arrays. You passed: {}={}'.format(field_name, orig_inp))


def check_generator_arguments(y=None, sample_weight=None,
                              validation_split=None):
  """Validates arguments passed when using a generator."""
  if

Ways to fix

votes up 1 votes down

Summary: 

This exception is thrown when the validate_input_types function is called. This function takes in 2 parameters: inp and orig_inp. An exception is thrown whenever the inp parameter is a value that is not a list, tuple, dictionary, or ndarray (from numpy). To avoid this exception make sure the value passed to the inp parameter is one of the supported types. The example of what is right and wrong below is simplified, but it highlights what triggers the exception very clearly.

Code to Reproduce the Error (WRONG):

import keras.engine.training_utils_v1 as ktu
import numpy as np

inp = np.array([1,2,3])
orig_inp = np.array([1,2,3])
ktu.validate_input_types(1, orig_inp) # Notice inp is an int

Working Version (Fixed):

import keras.engine.training_utils_v1 as ktu
import numpy as np

inp = np.array([1,2,3])
orig_inp = np.array([1,2,3])
ktu.validate_input_types(inp, orig_inp) # Notice inp is an array

Jul 06, 2021 codingcomedyig answer

Add a possible fix

Please authorize to post fix