W3 Exercise 2 Sigmoid

{ code removed by mentor }

In the 1st image, i cast z to float separately and it gives error but image 2, where i mention z’s dtype while initializing works fine.
What is the issue when I cast its type separately?

You didn’t assign the result from your tf.cast to any variable, so whatever returned by tf.cast won’t be saved anywhere. If this is not the problem, can you please share a screenshot of the full error traceback? Error traceback is important.


PS: I will remove the code since we can’t share assignment code here.

I am sorry, I totally forgot that I was posting the solution itself. And yes, that was the issue, i saved tf.cast to z and it worked. Thank you

Hello @strugrasp,

It’s fine :wink: , and it’s actually great to see that you found two different ways for doing that.


1 Like