'NoneType' object is not subscriptable

Firstly the notebook kept crashing and resetting and when everything worked and I submitted

I keep getting 50/100 and grader keeps coming back with

‘NoneType’ object is not subscriptable

Even though everything works in the collab and I haven’t used global variables

Sir can you please share the notebook you are using in PM to me

The error must be related to a usage of the notation […] which is intended for indexed access into a multi-valued object. The error means it is being applied to an object that is not actually multivalued. The fact that it ran in the collab but not in the grader suggests an edge case, like perhaps the return from a graded function where the notebook its local unit tests didn’t try this particular case.

Another place people run into this error is in the metrics = expression of a model compile statement. If you assign a single object there, for example

metrics=‘accuracy’

instead of

metrics=[‘accuracy’]

you may experience a not subscriptable error at runtime.

Thank you I fixed it
If you are using statements like
activation=‘relu’ or loss = [‘binary_crossentropy’] and statements like these try switching them to
tf.nn.relu and loss = losses.BinaryCrossentropy() respectively
Worked for me hope this helps

1 Like

Thanks @ai_curious @Ali_Ulas_Hayir for the explanations on how to solve the issue
It will definitely be useful for other fellow learners as well