You need to convert all the individual objects returned by both the training and validation generators to Numpy arrays:

    yield [np.array(imgs), np.array(cols)], np.array(targets)

Alternatively, a simpler and much more efficient solution is to not iterate over the data batch at all; instead, we can take advantage of the fact that these objects are already Numpy arrays when returned by ImageDataGenerator, so we can write:

    imgs = data[0]
    cols = data[1][:,:-1]
    targets = data[1][:,-1:]
    yield [imgs, cols], targets
Answer from today on Stack Overflow
🌐
GitHub
github.com › tensorflow › tensorflow › issues › 44285
training keras Sequential model with python generator raise error: AttributeError: 'tuple' object has no attribute 'rank' · Issue #44285 · tensorflow/tensorflow
October 24, 2020 - Describe the current behavior When training a Sequential model by fit function with python generator as inputs, it raise AttributeError: 'tuple' object has no attribute 'rank'. The python generator yield a tuple (x, y), which follows the tf document of fit function.
Author   over-shine
Discussions

tensorflow - AttributeError: 'tuple' object has no attribute 'rank' when using tensorflow_probability.layers.DenseVariational - Stack Overflow
I'm trying to use bayesian neural networks, adding a bayesian layer to a neural networks model. Here is the code I'm using and it's from the keras website. import numpy as np import tensorflow as t... More on stackoverflow.com
🌐 stackoverflow.com
July 10, 2024
tensorflow - layers.Dense - AttributeError: 'tuple' object has no attribute 'rank' " - Stack Overflow
Communities for your favorite technologies. Explore all Collectives · Ask questions, find answers and collaborate at work with Stack Overflow for Teams More on stackoverflow.com
🌐 stackoverflow.com
tensorflow2.0 - How to fix AttributeError: 'tuple' object has no attribute 'rank' creating a DqnAgent with Tensorflow? - Stack Overflow
I'm trying to create a DqnAgent using an own environment. But i'm receiving the following error AttributeError: 'tuple' object has no attribute 'rank' In call to configurable 'DqnAgent' ( More on stackoverflow.com
🌐 stackoverflow.com
February 28, 2021
AttributeError: 'tuple' object has no attribute 'rank'
Trying out the most basic example on Windows 10 Python 3.7 tensorflow 2.1.0 tf-agents 0.4.0 Error i get Traceback (most recent call last): File "src\agent.py", line 58, in ... More on github.com
🌐 github.com
15
May 3, 2020
🌐
LearnDataSci
learndatasci.com › solutions › python-attributeerror-tuple-object-has-no-attribute
Python AttributeError: 'tuple' object has no attribute – LearnDataSci
The underscore conveys to readers of your code that you intend not to use the index value. The error AttributeError: 'tuple' object has no attribute is caused when treating the values within a tuple as named attributes.
🌐
Stack Overflow
stackoverflow.com › questions › 78732706 › attributeerror-tuple-object-has-no-attribute-rank-when-using-tensorflow-pro
tensorflow - AttributeError: 'tuple' object has no attribute 'rank' when using tensorflow_probability.layers.DenseVariational - Stack Overflow
July 10, 2024 - To address this, you need to install keras 2 to ensure compatibility. Kindly, refer to this gist for your reference. ... Model definition in Keras tutorial "Probabilistic Bayesian Neural Networks" leads to error "AttributeError: 'tuple' object ...
🌐
Stack Overflow
stackoverflow.com › questions › 78564659 › layers-dense-attributeerror-tuple-object-has-no-attribute-rank
tensorflow - layers.Dense - AttributeError: 'tuple' object has no attribute 'rank' " - Stack Overflow
Getting the error "AttributeError: ‘tuple’ object has no attribute ‘rank’ " on the line : dense = layers.Dense(4, activation=act_func)(inputs), in the following function : def gen_model(act_func = 'relu'): inputs = keras.Input(shape=(4,)) dense = layers.Dense(4, activation=act_func)(inputs) dense = layers.Dense(4, activation=act_func)(dense) outputs = layers.Dense(1)(dense) model = keras.Model(inputs=inputs, outputs=outputs, name="NN_heat_controller") return model
Find elsewhere
🌐
Stack Overflow
stackoverflow.com › questions › 79558834 › tuple-has-no-attribute-rank-error-when-trying-to-build-bayesian-neural-net
python - tuple has no attribute "rank" error when trying to build bayesian neural net - Stack Overflow
import tensorflow as tf import tensorflow_probability as tfp # 0.25.0‑dev tfpl = tfp.layers inp = tf.keras.Input(shape=(10,)) print("[DEBUG] inp:", inp) print("[DEBUG] type(inp):", type(inp)) print("[DEBUG] inp.shape:", inp.shape) try: print("[DEBUG] inp.shape.rank:", inp.shape.rank) except Exception as e: print("[DEBUG] could not read rank →", e) print("[DEBUG] --------------------------------------------------") out = tfpl.DenseFlipout(16)(inp) # ← AttributeError: tuple has no attribute “rank” tf.keras.Model(inp, out) ... [DEBUG] inp: <KerasTensor shape=(None, 10), dtype=float32, s
🌐
Google AI
discuss.ai.google.dev › tensorflow › general discussion
layers.Dense - AttributeError: 'tuple' object has no attribute 'rank' " - General Discussion - Google AI Developers Forum
June 3, 2024 - I am getting the error "AttributeError: ‘tuple’ object has no attribute ‘rank’ " on the line : dense = layers.Dense(4, activation=act_func)(inputs), in the following function : def gen_model(act_func = ‘relu’): input…
🌐
Stack Overflow
stackoverflow.com › questions › 78902144 › model-definition-in-keras-tutorial-probabilistic-bayesian-neural-networks-lead
python - Model definition in Keras tutorial "Probabilistic Bayesian Neural Networks" leads to error "AttributeError: 'tuple' object has no attribute 'rank'" - Stack Overflow
AttributeError Traceback (most recent call last) <ipython-input-11-c94aabf54886> in <cell line: 5>() 3 small_train_dataset = train_dataset.unbatch().take(train_sample_size).batch(batch_size) 4 ----> 5 bnn_model_small = create_bnn_model(train_sample_size) 6 run_experiment(bnn_model_small, mse_loss, small_train_dataset, test_dataset) 2 frames /usr/local/lib/python3.10/dist-packages/tf_keras/src/engine/input_spec.py in assert_input_compatibility(input_spec, inputs, layer_name) 249 ) 250 if spec.min_ndim is not None: --> 251 ndim = x.shape.rank 252 if ndim is not None and ndim < spec.min_ndim: 253 raise ValueError( AttributeError: 'tuple' object has no attribute 'rank'
🌐
Stack Overflow
stackoverflow.com › questions › 78814295 › str-object-has-no-attribute-base-dtype-and-tuple-object-has-no-attribute
keras - 'str' object has no attribute 'base_dtype' and 'tuple' object has no attribute 'rank' when testing Kepler - Stack Overflow
July 31, 2024 - `I'm trying to replicate the Kepler project from Google Research (https://github.com/google/kepler) and encountered two errors that I can't seem to resolve. The first error is: AttributeError: 'tuple' object has no attribute 'rank' And the second error is: AttributeError: 'str' object has no attribute 'base_dtype'
🌐
Reddit
reddit.com › r/learnpython › getting attributeerror: 'tuple' object has no attribute 'items'
r/learnpython on Reddit: Getting AttributeError: 'tuple' object has no attribute 'items'
February 1, 2021 -
from kubernetes import client, config

config.load_kube_config()

v1 = client.CoreV1Api()
print("Listing services with their IPs:")
ret = v1.list_service_for_all_namespaces_with_http_info(watch=False)
for i in ret.items:
    print("%s\t%s\t%s" % (i.status.pod_ip, i.metadata.namespace, i.metadata.name))    

This throws this error: File "filename.py", line 8, in <module> for i in ret.items: AttributeError: 'tuple' object has no attribute 'items'

But when I simply print(ret), it certainly LOOKS like a tuple, which means I should be able to iterate through with tuple.items, no?

🌐
Bobby Hadz
bobbyhadz.com › blog › python-attributeerror-tuple-object-has-no-attribute
AttributeError: 'tuple' object has no attribute X in Python | bobbyhadz
April 8, 2024 - The Python "AttributeError: 'tuple' object has no attribute" occurs when we access an attribute that doesn't exist on a tuple.
🌐
DeepLearning.AI
community.deeplearning.ai › course q&a › deep learning specialization › sequence models
C5 W4 A1: Scaled_dot_product_attention AttributeError: 'tuple' object has no attribute 'rank' - Sequence Models - DeepLearning.AI
September 9, 2021 - C5 W4 A1: Scaled_dot_product_attention AttributeError: 'tuple' object has no attribute 'rank' · AttributeError Traceback (most recent call last) in 1 # UNIT TEST ----> 2 scaled_dot_product_attention_test(scaled_dot_product_attention) · Also, in “output = …”, you should consider using ...