C2W2 exercise 6 preprocessing_fn

I received teh following error from grader:

Failed test case: transformed_data incorrectly defined (showing changed values with respect to correct answer).
but got:
{“root[0][‘traffic_volume_xf’]”: {‘new_value’: 1, ‘old_value’: 0}, “root[3][‘traffic_volume_xf’]”: {‘new_value’: 1, ‘old_value’: 0}, “root[4][‘traffic_volume_xf’]”: {‘new_value’: 1, ‘old_value’: 0}}.

I wasn’t sure what mean function to use for this part, the only one I found was tf.reduce_mean:

tf.greater(traffic_volume, tf.reduce_mean(tf.cast(inputs[_VOLUME_KEY], tf.float32))),tf.int64)

Any tips? Thanks.

There’s also tft.mean

1 Like

Please click my name and message your notebook as an attachment if things don’t get sorted out.

Your tip worked, thanks! It would be nice to have this hint in the exercise description :slight_smile:

Sure. Informed the staff to add a hint.

Hi Team ,Possible to help me what I need to write in this section under preprocessing_fn function

Transform the strings into indices

# hint: use the VOCAB_SIZE and OOV_SIZE to define the top_k and num_oov parameters
    outputs[_transformed_name(key)] = tft.compute_and_apply_vocabulary(inputs[key]

Use tf.cast to cast the label key to float32

tf.greater(None,None,(tf.cast(inputs[_VOLUME_KEY], tf.float32)))

Sorry. I can’t send you any code that’s part of the assignment solution. That said, if you changed the assignment starter code by mistake, refresh the workspace to get a fresh copy of the assignment.

Please see this link.