Melp c2 , week 2 , assignment not working , excercise 6

i got error in week 2 assignment , excercise 6

What’s _fill_in_missing ?

I dunno , that’s the error i got

Remove _fill_in_missing since the notebook doesn’t contain its definition.

How to remove it ?
Please show me the cide to di so

Edit the cell where you created the traffic_transform.py file and run it again.

If that doesn’t help, click my name and message your notebook as an attachment.

i cant do it , please check

Please follow the steps here to refresh the workspace.

The starter code doesn’t contain the symbol _fill_in_missing.

Posting notebook / code in public is likely to get your account suspended. Please remove the python file from your previous reply. It’s okay to share stacktraces though. Here’s the community user guide to get started.

I removed ut as oer requested

Thanks. Try my suggestion and confirm if the error goes away.

A gentle reminder that there’s a difference between posting notebook in public and sending a direct message to a mentor upon request. The community user guide should help you figure that out. Also, a notebook has ipynb extension and not a py extension.

i got more errors , how to send file in private

Hello @Yomna_Mohamed click on his name, then select Message

@Yomna_Mohamed

Thanks for sending the ipynb file.
As mentioned in an earlier reply, you’ve added _fill_in_missing in your code when it’s not defined anywhere. It’s incorrect to use an undefind symbol as a function call. If this feedback confuses you, please become familiar with python before moving forward.

please show me where so i can remove it

Sure. Look at the python statement below this comment in your notebook:
# Use tf.cast to cast the label key to float32

i mean where in code cell not the error

It’s inside def preprocessing_fn(inputs): in line 67

i removed give the same error ,
even after definig it also give error

def _fill_in_missing(x):
“”“Replace missing values in a SparseTensor and convert to a dense tensor.
Fills in missing values of x with ‘’ or 0, and converts to a dense tensor.
Args:
x: A SparseTensor of rank 2. Its dense shape should have size at most 1
in the second dimension.
Returns:
A rank 1 tensor where missing values of x have been filled in.
“””
default_value = ‘’ if x.dtype == tf.string else 0

return tf.squeeze(
  tf.sparse.to_dense(
      tf.SparseTensor(x.indices, x.values, [x.dense_shape[0], 1]),
      default_value),
  axis=1)

There are 2 mistakes in def preprocessing_fn(inputs): in line 67:

  1. Indentation of the line traffic_volume = ... has an extra leading space.
  2. Get rid of the function call to _fill_in_missing and use tf.cast directly.

Please type how to use tf.cast directly, as i did , gives error