C2W2 Issue in greater than fn code

Issue is in the last line. error is Tensor not callable.

Unable to write the greater than comparison part, need help on this. Is there any example in the TF documentations or the ungraded labs, I checked everywhere and could not find one.

Following confusion:

  • what to type cast and what not in traffic_volume and its mean
  • How to write traffic_volume for a row ??

traffic_volume is a column in inputs. You want to perform 2 operations:

  1. Calculate mean of traffic_volume column.
  2. For each row of traffic_volume, if it’s greater than the mean value calculated in the previous step, map the boolean value True to 1 else 0.
    Here’s the documentation for tf.greater

I am sorry I still have the same Qs.

I have understood the 2 points mentioned, but my doubts are still:

  • to typecast both of these values or not?
    *How to write traffic_volume for a row ??

When you perform an operation where one side is a scalar and other side is an nd-array, the operation is broadcast to all entries. Here’s an example where 1 is added to all entries of a vector and a new tensor is returned:

>>> vec = tf.constant([1,2,3,4,5])
>>> vec + 1
<tf.Tensor: shape=(5,), dtype=int32, numpy=array([2, 3, 4, 5, 6], dtype=int32)>

Assume that traffic_volume = [1,2,3,4,5]. There are 5 rows worth data here.

  1. Mean of traffic_value is 3.
  2. Use tf.greater to create a result of the form [False, False, False, True, True] by comparing each entry of traffic_volume with the mean value.
  3. Integer encode the result to produce [0, 0, 0, 1, 1]
2 Likes