#πŸ”’ Tensorflow Transfer Learning Error

30 messages Β· Page 1 of 1 (latest)

vital lotus
#

I keep getting this error when running my code:

ValueError: Only instances of keras.Layer can be added to a Sequential model. Received: <tensorflow.python.keras.layers.core.Flatten object at 0x0000014E1944C8D0> (of type <class 'tensorflow.python.keras.layers.core.Flatten'>)

I'm relatively new to python and tensorflow so I'm not sure why I keep running into this error. I've ran into a similar issue before and also couldn't resolve that one. Any help is appreciated.

I have more code than the image, but I believe the error should be stemming from an issue there.

fallen canyonBOT
#

@vital lotus

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

finite quarry
#

bro write:
keras.Layer()

vital lotus
finite quarry
#

class.nameof_function()

vital lotus
#

I'm sorry could you use laymans terms? Like I said, I'm new. Also, that doesn't seem to be a place in code?

hoary wing
#

@vital lotus hey there. well, first of all: make sure to paste the code as text in discord with a code block like this:
```py
<code>
```
or use a discord's pastebin, cuz screenshots are painful to read. But anyways

#

what exactly are u trying to do here

#

you're trying to add a layer into a network, and, it expects a layer as an argument

vital lotus
#

In the tutorial I was following, that line was intended to flatten to one dimension I believe

hoary wing
#

in the docs adding a layer looks like this:

model.add(layers.Dense(2, activation="relu"))

(which, well, adds a new layer)

vital lotus
#

Are you saying that resnet_model.add(Flatten()) is adding another layer and not flattening like it was supposed to?

vital lotus
# hoary wing weird stuff

I also plugged into chat gpt to see what it had to see what it had to say and it said the issue for that error was in from this, but I'm not sure

#

I see now, that is odd. Maybe I can just try to find another way to flatten to one dimension?

hoary wing
hollow fog
vital lotus
hoary wing
#

ahh, wait

#

if u want to flatten a layer, you need a layer πŸ’€

vital lotus
#

Haha gotcha. I also think the issue is importing dense and flatten. I had .python in and removed it and it worked. The tutorial may have been an older version and I think that changed for the newer version I’m on

#

So that error is gone, I just have to work through a bunch of other errors now πŸ’€

hoary wing
vital lotus
#

That’s cool, thanks for your help though!

hoary wing
fallen canyonBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.