Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Fix the bug of BidirectionalCell #13575

Merged
merged 8 commits into from
Dec 13, 2018
Merged

Fix the bug of BidirectionalCell #13575

merged 8 commits into from
Dec 13, 2018

Conversation

BeyonderXX
Copy link
Contributor

@BeyonderXX BeyonderXX commented Dec 7, 2018

Description

I did hybridize( ) and pass "valid_length" to the unroll( ) function of BidirectionalCell, then returned AssertionError in line 79. Because symbol.split( ) return a symbol but not a symbol list. Result in the length of inputs is not equal to parameter "length" when call unroll( ) to compute r_outputs and r_states. Symbol support for converting to list through list( ) API, so that use list( ) function insted of _as_list( ).

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

python/mxnet/gluon/rnn/rnn_cell.py

  • [line 1055] [line 1069]add _reverse_sequences( ) to calculate "reversed_inputs" and "reversed_r_outputs"
  • [line 1055] use list( ) instead of _as_list( )

tests/python/unittest/test_gluon_rnn.py

  • [line 603] add test_bidirectional_unroll_valid_length( ) to test the unroll( ) of BidirectionalCell when pass
    valid_length to it.

I did hybridize( ) and pass "valid_length" to the unroll( ) function of BidirectionalCell, then returned AssertionError in line 79. Because symbol.split( ) return a symbol but not a symbol list. Result in the length of inputs dont equal parameter "length"  when call unroll( )  to compute r_outputs and r_states.
@BeyonderXX BeyonderXX requested a review from szha as a code owner December 7, 2018 11:56
Copy link
Contributor

@larroy larroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im confused, doesn't _as_list return a list?

def _as_list(obj):
    """A utility function that converts the argument to a list if it is not already.

    Parameters
    ----------
    obj : object

    Returns
    -------
    If `obj` is a list or tuple, return it. Otherwise, return `[obj]` as a
    single-element list.

    """
    if isinstance(obj, (list, tuple)):
        return obj
    else:
        return [obj]

I don't understand the fix. Can you paste the error?

@nswamy nswamy added pr-awaiting-review PR is waiting for code review and removed pr-awaiting-review PR is waiting for code review labels Dec 8, 2018
@szha
Copy link
Member

szha commented Dec 8, 2018

@larroy _as_list would return a wrong list as it would wrap the single grouped symbol inside, instead of length number of tensors for each time-step, which is what the output should be.

@szha
Copy link
Member

szha commented Dec 8, 2018

@BeyonderXX thanks for the fix. Could you add a test with the proper assertions?

@BeyonderXX
Copy link
Contributor Author

BeyonderXX commented Dec 8, 2018

@BeyonderXX thanks for the fix. Could you add a test with the proper assertions?

I‘m glad to! I will add a new test case as soon as possible.

BeyonderXX and others added 3 commits December 10, 2018 00:00
I did hybridize( ) and pass "valid_length" to the unroll( ) function of BidirectionalCell, then returned AssertionError in line 79. Because symbol.split( ) return a symbol but not a symbol list. Result in the length of inputs dont equal parameter "length"  when call unroll( )  to compute r_outputs and r_states.
BeyonderXX and others added 3 commits December 10, 2018 13:19
I did hybridize( ) and pass "valid_length" to the unroll( ) function of BidirectionalCell, then returned AssertionError in line 79. Because symbol.split( ) return a symbol but not a symbol list. Result in the length of inputs dont equal parameter "length"  when call unroll( )  to compute r_outputs and r_states.
@BeyonderXX
Copy link
Contributor Author

BeyonderXX commented Dec 10, 2018

@szha I reproduced the issue in windows, when pass valid_length to unroll( ) of BidirectionalCell, it would raise null pointer error after multiple calls.

@BeyonderXX
Copy link
Contributor Author

@szha I figured out the issue, because I passed a wrong parameter to unroll( ) which led to out of bounds. I have fixed the problem and rewrited my code in BidirectionalCell. So sorry to disturb you abruptly. Thanks!

@szha
Copy link
Member

szha commented Dec 13, 2018

@BeyonderXX thanks for the fix!

zhaoyao73 added a commit to zhaoyao73/incubator-mxnet that referenced this pull request Dec 13, 2018
* upstream/master: (38 commits)
  Feature/mkldnn static (apache#13628)
  Fix the bug of BidirectionalCell (apache#13575)
  Set install path for libmxnet.so dynamic lib on Mac OS (apache#13629)
  add batch norm test (apache#13625)
  Scripts for building dependency libraries of MXNet (apache#13282)
  fix quantize pass error when the quantization supported Op are excluded in the model (apache#13596)
  Optimize C++ API (apache#13496)
  Fix warning in waitall doc (apache#13618)
  [MXNET-1225] Always use config.mk in make install instructions (apache#13364)
  [MXNET-1224]: improve scala maven jni build and packing. (apache#13493)
  [MXNET-1155] Add scala packageTest utility (apache#13046)
  fix the Float not showing correctly problem (apache#13617)
  apache#13385 [Clojure] - Turn examples into integration tests (apache#13554)
  Add Intel MKL blas to Jenkins (apache#13607)
  Revert "[MXNET-1198] MXNet Java API (apache#13162)"
  Reducing the length of setup tutorial (apache#13306)
  [MXNET-1182] Predictor example (apache#13237)
  [MXNET-1187] Added Java SSD Inference Tutorial for website (apache#13201)
  add defaults and clean up the tests (apache#13295)
  [MXNET-1181] Added command line alternative to IntelliJ in install instructions (apache#13267)
  ...
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pr-awaiting-review PR is waiting for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants