really really need some help
{moderator edit - solution code removed}
really really need some help
{moderator edit - solution code removed}
When you use the Sequential model, youâre creating a python list.
This means the layers must be within a set of square brackets, and be separated by commas.
In the assert in your second image, youâre missing a comma before âdata_formatâ.
Also, please donât post your code on the forum. That breaks the community standards.
If a mentor needs to see your code, weâll ask you to send it via a private message.
There are two different methods here: the Keras Sequential API and the Keras Functional API.
In the Sequential case, you only instantiate the âlayerâ functions and then make list with commas, as Tom pointed out.
In the Functional case, you both instantiate the âlayersâ and then actually invoke them with an input tensor. No commas required.
You are using the Sequential method, but you omitted the commas and the syntax that closes off the list and the Sequential declaration.
You can argue that they did not really give us much to go on here. You would probably be well served to spend a bit of time reading through this thread from fellow student ai_curious about how these two methods work.
I placed the layers within two square brackets. and also placed the comma before âdata_formatâ
Iâm still getting a syntax error
And also placed commas between each of the layers. Iâm still getting a syntax error
Course policy does prohibit posting solutions (source code) but itâs hard to help with syntax errors without seeing the error message itself. Remember that Python syntax errors are reported by the parser; there is something fundamentally out of compliance with the language specification. Further, The parser repeats the offending line and displays a little âarrowâ pointing at the earliest point in the line where the error was detected. The error is caused by (or at least detected at) the token preceding the arrow
https://docs.python.org/3/tutorial/errors.html
Maybe start at the indicated token and work backwards, looking for typographic errors too. And share the particular error youâre getting.
{mentor edit: code removed - the problem was a missing comma in the parameter list)
this is it
I just checked. the arrow is on the âlâ of âtflâ. I dont get why thats the case. the instructions in the assignment stated we could use tfl in place of tensorflow.keras.layers
Well, that looks like source code again, not the error message, but ok. Compare what you have to what is on the Keras doc page.
tf.keras.layers.ReLU(
max_value=None, negative_slope=0.0, threshold=0.0, **kwargs
)
Look carefully at the list, ahem, of parameters
This is the error
You have to be very careful when you mix named and unnamed parameters in the same layer definition.
If you donât name the parameters, âstridesâ is defined as the third value.
But you have both an unnamed third value, and then you also have a named strides parameter.
Check the definition for the Keras Conv2D layer:
Both the ReLU and Conv2D syntax errors have the same root cause; non-compliance with the documented function parameters. I never saw the code, but it seems like the original Sequential error was, too. So my advice would be to get in the practice of really looking carefully at the official documentation and any examples provided there when you write your code. Do a detailed comparison and understand whether the differences will cause trouble. There might also be some benefit from an editor that supports typeahead, such as Jupyter Lab (instead of Notebook). Especially until you develop more fluency. HTH
Thank you for the tips. Iâve been able to complete the exercise. took me a whole day but I think Iâve learnt a thing or two. Thank you