Error with Sequential()

Hi, i am just starting with Tensorflow for my AI and i ran into an error i don’t know how to solve

[2021-09-06 21:55:50.461476: I tensorflow/core/platform/] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX2

To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.

2021-09-06 21:55:51.050032: I tensorflow/core/common_runtime/gpu/] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 2781 MB memory: -> device: 0, name: NVIDIA GeForce GTX 970, pci bus id: 0000:01:00.0, compute capability: 5.2 UserWarning: The `lr` argument is deprecated, use `learning_rate` instead.


2021-09-06 21:55:51.508673: I tensorflow/compiler/mlir/] None of the MLIR Optimization Passes are enabled (registered 2)

Epoch 1/200

Traceback (most recent call last):

File “”, line 69, in <module>, np.array(training_2), epochs=200, batch_size=5, verbose=2)

File ““, line 1184, in fit

tmp_logs = self.train_function(iterator)

File “”, line 885, in __call__

result = self._call(*args, **kwds)

File “”, line 933, in _call

self._initialize(args, kwds, add_initializers_to=initializers)

File “”, line 759, in _initialize

self._stateful_fn._get_concrete_function_internal_garbage_collected( # pylint: disable=protected-access

File ““, line 3066, in _get_concrete_function_internal_garbage_collected

graph_function, _ = self._maybe_define_function(args, kwargs)

File ““, line 3463, in _maybe_define_function

graph_function = self._create_graph_function(args, kwargs)

File ““, line 3298, in _create_graph_function


File “”, line 1007, in func_graph_from_py_func

func_outputs = python_func(*func_args, **func_kwargs)

File “”, line 668, in wrapped_fn

out = weak_wrapped_fn().__wrapped__(*args, **kwds)

File “”, line 994, in wrapper

raise e.ag_error_metadata.to_exception(e)

TypeError: in user code: train_function *

return step_function(self, iterator) step_function **

outputs =, args=(data,)) run

return self._extended.call_for_each_replica(fn, args=args, kwargs=kwargs) call_for_each_replica

return self._call_for_each_replica(fn, args, kwargs) _call_for_each_replica

return fn(*args, **kwargs) run_step **

outputs = model.train_step(data) train_step

y_pred = self(x, training=True) __call__

outputs = call_fn(inputs, *args, **kwargs) call

return super(Sequential, self).call(inputs, training=training, mask=mask) call

return self._run_internal_graph( _run_internal_graph

outputs = node.layer(*args, **kwargs) __call__

outputs = call_fn(inputs, *args, **kwargs) call

output = control_flow_util.smart_cond(training, dropped_inputs, smart_cond

return tf.__internal__.smart_cond.smart_cond( smart_cond

return true_fn() dropped_inputs

noise_shape=self._get_noise_shape(inputs), _get_noise_shape

for i, value in enumerate(self.noise_shape):

TypeError: ‘int’ object is not iterable]

I guess it’s about the line but i am not sure, for reference here is a bit of my code:

[training_1 = list(training_ai[:,0])

training_2 = list(training_ai[:,1])

model = Sequential()

model.add(Dense(128, input_shape=(len(training_1[0]),),activation=’relu’))


model.add(Dense(64, activation = ‘relu’))



sgd = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)

model.compile(loss=’categorical_crossenropy’, optimizer=sgd, metrics=[‘accuracy’]), np.array(training_2), epochs=200, batch_size=5, verbose=2)]

I would be happy if you could help me with this Error

submitted by /u/HeroOfComputers
[visit reddit] [comments]

Leave a Reply

Your email address will not be published. Required fields are marked *