Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SoftMax to work in spatial mode #370

Merged
merged 1 commit into from
Sep 23, 2015
Merged

Conversation

jhjin
Copy link
Contributor

@jhjin jhjin commented Sep 9, 2015

The module applies softmax in space and works both on a single
vector/matrix (1D/2D) or spatial vector/matrix (3D/4D).

@jhjin
Copy link
Contributor Author

jhjin commented Sep 9, 2015

One concern is that the backend is similar to nn.SoftMax and mostly indexing is different. It might be redundant to keep this code along with nn.SoftMax.

@soumith
Copy link
Member

soumith commented Sep 14, 2015

@jhjin we could have a C implementation that is shared between SoftMax and SpatialSoftMax, and for the future, VolumetricSoftMax. If you send a PR at a later date to refactor that, I am happy to accept.

@jhjin
Copy link
Contributor Author

jhjin commented Sep 14, 2015

@soumith thanks for the comment. will do that!

@soumith
Copy link
Member

soumith commented Sep 18, 2015

@jhjin found a bug. if the gradOutput is non-contiguous, you will get wrong results. Similar to how you added newContiguous for input, I suppose you could do the same with gradOutput

This updates SoftMax to work in spatial mode thus it accepts 1D/2D/3D/4D
tensor as input. New SpatialSoftMax module is also added and it shares
the C implementation with SoftMax.
@jhjin jhjin changed the title Add SpatialSoftMax module Update SoftMax to work in spatial mode Sep 19, 2015
@jhjin
Copy link
Contributor Author

jhjin commented Sep 19, 2015

@soumith I've updated the branch to reflect the non-contiguous gradOutput/output issue. Similar changes were made in cunn as well torch/cunn#135

soumith added a commit that referenced this pull request Sep 23, 2015
Update SoftMax to work in spatial mode
@soumith soumith merged commit 8798d23 into torch:master Sep 23, 2015
@soumith
Copy link
Member

soumith commented Sep 23, 2015

thanks a lot Jong!

@culurciello
Copy link
Contributor

well done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants