CopyTypeError: The added layer must be an instance of class Layer
You have created model using keras.models.Model while you are adding a layer from tensorflow.keras.layers.
Note that keras and tensorflow.keras is different. Make sure that you stick with one of them.
python 3.x - In accessing intermediate layers of keras pretrained model - error message: "AttributeError: 'tuple' object has no attribute 'layer'" - Stack Overflow
AttributeError: 'tuple' object has no attribute 'layer' when using ActivationsVisualizationCallback
python - AttributeError: 'tuple' object has no attribute - Stack Overflow
python - How to fix 'tuple' object has no attribute 'layer'? - Stack Overflow
Videos
You have imported layers from tensorflow.keras while other functions you have imported from keras. You can either import your layers from keras or try importing other functions from tensorflow.keras which might work.
I am only new in Python and deep learning. But I wanted to share this, as it helped me with a similar error. Maybe, in the importing section, try:
import tensorflow.keras
For all the rest you have to import from keras, keep the tensorflow. in front. And type it as a whole when using anything from keras later. Eg:
model.add(tensorflow.keras.layers.Conv2D())
Then you will not need: import tensorflow as tf
The tuple probably refers to your input_shape. What I mention above solved my problem.
I cannot answer why exactly this happens, though.
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!"
Version conflict of tensorflow and keras. Solved by changing it to tf 1.14.
Apparently not all TensorFlow 2.0 packages support Python 3.7
this worked for me
conda create -y --name tensorflow python=3.6
type in this before entering the environment
Copyconda activate tensorflow
I have FOUND the ANSWER
infc = arcpy.GetParameterAsText(0)
repnum = arcpy.GetParameterAsText(1)
gRows = arcpy.da.SearchCursor(infc, "Shape@")
for row in gRows:
origpoly = row
del gRows
aRows = arcpy.da.InsertCursor(infc, "Shape@")
for x in xrange(0, int(repnum)):
aRows.insertRow(origpoly)
del aRows
it would be easier to combine with arcpy.da.InsertCursor. Note that in your code the row[1] value is the shape field.
EDIT: as you found out, the main problem came from the use of 2 cursors together (and my first suggestion to use an edit session did not solve that).
polygons_shape="C:\\temp\\FinalLayers.gdb\\FinalLayers\\Polygons"
fields=('ID','SHAPE@','Comment','owner')
ID= arcpy.da.SearchCursor(polygons_shape,fields)
list_rows=[]
for row in ID:
if row[0]>1:
list_rows.append(row)
del ID
Insertc = arcpy.da.InsertCursor(polygons_shape, fields)
for newrow in list_rows:
for i in range(newrow[0]):
Insertc.insertRow(newrow)
del Insertc
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.