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 OverflowYou 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
A different solution worked for me, just posting it here. I ran into the problem working with two very similar dataframes in one notebook, where for one of them the error occurred. I noticed the dtypes were slightly different int64 vs Int64, where the target column coded as Int64 gave the error.
For me the following worked:
dataframe[target_col] = dataframe[target_col].astype(int)
tensorflow - AttributeError: 'tuple' object has no attribute 'rank' when using tensorflow_probability.layers.DenseVariational - Stack Overflow
tensorflow - layers.Dense - AttributeError: 'tuple' object has no attribute 'rank' " - Stack Overflow
tensorflow2.0 - How to fix AttributeError: 'tuple' object has no attribute 'rank' creating a DqnAgent with Tensorflow? - Stack Overflow
AttributeError: 'tuple' object has no attribute 'rank'
Videos
You return four variables s1,s2,s3,s4 and receive them using a single variable obj. This is what is called a tuple, obj is associated with 4 values, the values of s1,s2,s3,s4. So, use index as you use in a list to get the value you want, in order.
Copyobj=list_benefits()
print obj[0] + " is a benefit of functions!"
print obj[1] + " is a benefit of functions!"
print obj[2] + " is a benefit of functions!"
print obj[3] + " is a benefit of functions!"
You're returning a tuple. Index it.
Copyobj=list_benefits()
print obj[0] + " is a benefit of functions!"
print obj[1] + " is a benefit of functions!"
print obj[2] + " is a benefit of functions!"
I am trying to make a discord bot that would turn a message into lowercase. I am encountering an error, as the title suggests, "AttributeError: 'tuple' object has no attribute 'lower'. "
Here is my code if anyone can help.
https://hastebin.com/ibareyilax.py
If this is the wrong subreddit I don't mind taking down my post and posting it elsewhere.
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?