Hi, I would need some help to figure out why I get error in optimize() function:
I counted grads and costs like this:
[code removed - moderator]
Why does it return “TypeError: ‘float’ object is not subscriptable”?
[code removed - moderator]
Hi, I would need some help to figure out why I get error in optimize() function:
I counted grads and costs like this:
[code removed - moderator]
Why does it return “TypeError: ‘float’ object is not subscriptable”?
[code removed - moderator]
learning_rate
is a float. You can use it directly like x -= learning_rate * y
The learning rate is a Python float
object, i.e. a floating point number. For example the statement learning_rate = .01
implies that learning_rate
is of Python type float
. You have apparently tried to access an element of learning_rate
as if it were an iterable (e.g. a Python list
object). That would like something like learning_rate[0]
to access the first element. Since learning_rate
is not an iterable, but rather a float
, your code has thrown the TypeError
exception. You need to think about whatever logic you applied to arrive at the conclusion that learning_rate
is “list-like”.
Thank you for your response and help! It was a stupid mistake from me, I got confused because of for-loop and tried to force index i somewhere. Problem is solved now.