Course 2, Week 3 - sigmoid function

Hi, for sigmoid of 12, I get 0.9999938 instead of 0.9999939. (See below). Any ideas on what to do to get this to match exactly so I don’t get an assertion error? Thanks

type: <class ‘tensorflow.python.framework.ops.EagerTensor’>
dtype: <dtype: ‘float32’>
sigmoid(-1) = tf.Tensor(0.26894143, shape=(), dtype=float32)
sigmoid(0) = tf.Tensor(0.5, shape=(), dtype=float32)
sigmoid(12) = tf.Tensor(0.9999938, shape=(), dtype=float32)

AssertionError Traceback (most recent call last)
in
16 print("\033[92mAll test passed")
17
—> 18 sigmoid_test(sigmoid)

in sigmoid_test(target)
12 assert sigmoid(0) == 0.5, “Error”
13 assert sigmoid(-1) == 0.26894143, “Error”
—> 14 assert sigmoid(12) == 0.9999939, “Error”
15
16 print("\033[92mAll test passed")

AssertionError: Error

Problem solved… you must use the built-in function rather than compute the sigmoid yourself.

@DavidS999 Great to hear you solved it yourself. Thanks for sharing it in the community!

could you please teach how did you use build in function
I am stuck in this part too.

Here I write this way function :-

z = tf.cast(“z”, tf.float32)
a = tf.keras.activations.sigmoid(“z”)

1 Like

Perhaps those quotes are getting in your way…

Hi, I am having the same error and I am using all in-built functions explained in the notebook. Pls help.

Update: This is weird, I am getting error while doing the assignment on my PC but there is no error while doing it in coursera labs.

Checked the versions of TF2, I have 2.4.0 and labs has 2.3.0.

But why a version change is affecting the result? :thinking: