Giter VIP home page Giter VIP logo

Comments (4)

wj926 avatar wj926 commented on June 25, 2024

I solved this problem by using --batch_size 300

from arae.

kellywzhang avatar kellywzhang commented on June 25, 2024

Hello! So I've also run into the same issue and it seems to depend on the version of PyTorch that you're using. So the code at line 202 in models.py hidden = torch.div(hidden, norms.expand_as(hidden)) worked in the last major release version of PyTorch. For the newest release of PyTorch I've had to change it to hidden = torch.div(hidden, norms.unsqueeze(1).expand_as(hidden)).

Basically this section of the code finds the L2 norm for each of the hidden vectors / codes in the batch, and then divides the hidden vectors by the L2 norm to normalize them into unit vectors. The problem is just that of PyTorch syntax in changing the dimension of the norm to prepare it for the division.

Let me know if you have any more issues related to this.

from arae.

shaform avatar shaform commented on June 25, 2024

Thanks, this indeed solved the problem.
For reference, in v0.1.12 torch.norm always keep dims:

The output Tensor is of the same size as input except in the dimension dim where it is of size 1.
http://pytorch.org/docs/0.1.12/torch.html?highlight=norm#torch.norm

But in v0.2.0, the behavior was changed:

If keepdim is true, the output Tensor is of the same size as input except in the dimension dim where it is of size 1. Otherwise, dim is squeezed.
http://pytorch.org/docs/0.2.0/torch.html?highlight=norm#torch.norm

from arae.

JulesGM avatar JulesGM commented on June 25, 2024

#9 (comment) I think this should be uncommented by default now.. it's been almost a year

from arae.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.