Skip to content

Conversation

@Chillee
Copy link
Collaborator

@Chillee Chillee commented Jun 25, 2019

#2118

I'm not sure I'm doing it correctly, so I'll add tests if we decide that it's roughly correct.

@Chillee Chillee requested review from fmassa and jamesr66a June 25, 2019 23:43
@pytorchbot pytorchbot added the module: nn Related to torch.nn label Jun 25, 2019
Copy link
Collaborator

@ssnl ssnl left a comment

Choose a reason for hiding this comment

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

also need a test

@Chillee Chillee requested a review from ssnl June 27, 2019 20:51
@Chillee Chillee force-pushed the addflatten branch 2 times, most recently from 5e9fff8 to 6f0deb0 Compare June 28, 2019 02:45
Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

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

This looks good, thanks!

Can you also add an entry in the documentation in https://github.com/pytorch/pytorch/blob/master/docs/source/nn.rst

@pytorchbot pytorchbot added the module: docs Related to our documentation, both in docs/ and docblocks label Jul 9, 2019
@Chillee
Copy link
Collaborator Author

Chillee commented Jul 9, 2019

Done. Hopefully I added it to the rst file properly...

@Chillee Chillee requested review from fmassa and ssnl July 9, 2019 05:49

Shape:
- Input: :math:`(N, *dims)
- Output: :math:`(N, product of dims)`
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is still inaccurate...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's not entirely clear to me what's desired here. If we want to be completely accurate we could do (N, \prod_{i=\text{start\_dim}}^{\text{end\_dim+1}} \text{dims[i]}, *dims[end_dim+1:]), which renders like
image.

I'd also appreciate other suggestions on how to write this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Even mentioning N is not quite right. The default arguments works for batched tensors, but it doesn't have to be batched. Since you already mentioned what the two dims are, instead of saying the general case, can you just say that explicitly, for the default arguments, what the input and output shapes are?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry I'm not sure I understand your comment. If I were to say "explicitly, for the default arguments, what the input and output shapes are", I'd write what I had originally + a note that this is for the default arguments. Is that correct?

@Chillee Chillee requested a review from ssnl July 15, 2019 22:34
@Chillee
Copy link
Collaborator Author

Chillee commented Jul 15, 2019

I've updated the docs - I hope I interpreted your comment correctly @ssnl

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@Chillee has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@Chillee has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@Chillee merged this pull request in 1c00e0f.

@PistonY
Copy link

PistonY commented Aug 16, 2019

It seems that 'nn.Flatten' missed in '.pyi' file, Pycharm can't find it'

facebook-github-bot pushed a commit that referenced this pull request Aug 17, 2019
Summary:
Generated with `stubgen` and moved from `out/flatten.pyi` to `flatten.pyi.in`.

#22245 (comment)
Pull Request resolved: #24459

Differential Revision: D16881182

Pulled By: ezyang

fbshipit-source-id: 5e25fad55f169b5a58ab7522b583d7c923314d4d
@ptrblck
Copy link
Collaborator

ptrblck commented Sep 1, 2019

The documentation seems to be empty in 1.2.0 and master:
https://pytorch.org/docs/stable/nn.html#flatten

@Chillee
Copy link
Collaborator Author

Chillee commented Sep 2, 2019

@ptrblck whoops I think the currentmodule annotation screwed it up - I'll put up a PR fixing it.

@facebook-github-bot facebook-github-bot deleted the addflatten branch July 13, 2020 17:53
facebook-github-bot pushed a commit that referenced this pull request Jul 21, 2020
Summary:
This PR implements a feature extension discussed in #41516.

I followed this other PR #22245 to add this other module. While I was at it, I also added `extra_repr()` method in `Flatten` which was missing.

I see there are no unit tests for these modules. Should I add those too? If so, what is the best place I should place these?

Pull Request resolved: #41564

Reviewed By: gchanan

Differential Revision: D22636766

Pulled By: albanD

fbshipit-source-id: f9efdefd3ffe7d9af9482087625344af8f990943
facebook-github-bot pushed a commit that referenced this pull request Jul 27, 2020
Summary:
I've noticed when PR #22245 introduced `nn.Flatten`, the docstring had a bug where it wouldn't render properly on the web, and this PR addresses that. Additionally, it adds a unit test for this module.

**Actual**
![image](https://user-images.githubusercontent.com/13088001/88483672-cf896a00-cf3f-11ea-8b1b-a30d152e1368.png)

**Expected**
![image](https://user-images.githubusercontent.com/13088001/88483642-86391a80-cf3f-11ea-8333-0964a027a172.png)

Pull Request resolved: #42084

Reviewed By: mrshenli

Differential Revision: D22756662

Pulled By: ngimel

fbshipit-source-id: 60c58c18c9a68854533196ed6b9e9fb0d4f83520
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged module: docs Related to our documentation, both in docs/ and docblocks module: nn Related to torch.nn

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants