ivy icon indicating copy to clipboard operation
ivy copied to clipboard

Update nn.py with conv_transpose function (#17990)

Open ViktorTurchenko opened this issue 1 year ago • 5 comments

#17990 Created a conv_transpose function. I don't understand how many dimensions is it supposed to have (like 1 in Conv1D). So I added an n to pass this argument into the function. Please explain further the functionality that is supposed to be implemented as I could find any alike function in the TensorFlow documentation. Thanks!

ViktorTurchenko avatar Jun 28 '23 15:06 ViktorTurchenko

If you are working on an open task, please edit the PR description to link to the issue you've created.

For more information, please check ToDo List Issues Guide.

Thank you :hugs:

ivy-leaves avatar Jun 28 '23 15:06 ivy-leaves

Hi @ViktorTurchenko! Thank you for contributing to Ivy :hugs: 2 little things though:

  • Please edit the PR description to correctly link an issue, you edited the title of the PR.
  • In any case, a frontend must exactly match the framework's function signature. So you can't pass in a n argument here. This conv_transpose would call conv1d_transpose, conv2d_transpose or conv3d_transpose based solely on the data shape of the inputs passed in. You would have to infer input, filters, data_format or dilations to get the correct N that is specified in the function's documentation.

xoiga123 avatar Jun 30 '23 11:06 xoiga123

I have 3 more questions:

  1. If we are deciding which function to use with the data_format argument may I move it so it is a compulsory argument?
  2. If no then what default value should I use (most users will get errors if they don't change and their data is not matching the format needed)?
  3. Should I check the 3-rd condition with a elif statement and for everything else raise some kind of an error? Thanks for your time!

ViktorTurchenko avatar Jun 30 '23 14:06 ViktorTurchenko

  1. We will have to keep it exactly the same. Probably you shouldn't if-else on an Optional keyword argument. It says on the docs that data_format depends on N being figured elsewhere (input and filters):

For N=1, the valid values are "NWC" (default) and "NCW". For N=2, the valid values are "NHWC" (default) and "NCHW". For N=3, the valid values are "NDHWC" (default) and "NCDHW".

  1. Depends on required arguments.
  2. Yeah we should raise an ivy.utils.exceptions.IvyException if the inputs are wrong, don't default everything to an else in this case.

xoiga123 avatar Jun 30 '23 14:06 xoiga123

I changed the if-else to a required argument and added the exception at the end. Sorry I haven't read the documentation enough to understand the required formats 😃

ViktorTurchenko avatar Jun 30 '23 14:06 ViktorTurchenko

@handle_frontend_test( fn_tree="tensorflow.nn.conv_transpose", x_f_d_df=_x_and_filters( dtypes=helpers.get_dtypes("float", full=False), data_format=st.sampled_from(["NDHWC"]), padding=st.sampled_from(["SAME"]), type="3d", transpose=True, ), test_with_out=st.just(False), )

For the frontend test part what type= argument should be inserted?

ViktorTurchenko avatar Jul 04 '23 15:07 ViktorTurchenko

For the frontend test part what type= argument should be inserted?

You're going to have to sample from 1d, 2d or 3d as conv_transpose is all 3 of them.

xoiga123 avatar Jul 04 '23 19:07 xoiga123

This PR has been labelled as stale because it has been inactive for more than 7 days. If you would like to continue working on this PR, then please add another comment or this PR will be closed in 7 days.

ivy-seed avatar Jul 14 '23 05:07 ivy-seed

This PR has been closed because it has been marked as stale for more than 7 days with no activity.

ivy-seed avatar Jul 23 '23 05:07 ivy-seed