Giter VIP home page Giter VIP logo

Comments (4)

hzhwcmhf avatar hzhwcmhf commented on June 12, 2024

@thangld201
I am not sure but here are some possible causes:

  • BLEU calculation may be slow.
  • A classifier is used to determine the style.

To eliminate these effects, can you measure the time between this lines?

with torch.no_grad():
rev_log_probs, gen_lengths, _, _, allpos = self.net.model_F(
inp_tokens,
inp_lengths,
None,
None,
rev_styles,
generate=True,
differentiable_decode=False,
temperature=temperature,
use_inference_z = (self.now_batch-self.args.F_pretrain_iter) > self.args.pre_z_batch
)

from nast.

thangld201 avatar thangld201 commented on June 12, 2024

@hzhwcmhf , I found that Line 334: predict_res.append(self.param.volatile.cls.predict_str(sents)) was the cause (took up 99% of the time). I will dive a bit more....not sure why this is slow...

from nast.

hzhwcmhf avatar hzhwcmhf commented on June 12, 2024

@hzhwcmhf , I found that Line 334: predict_res.append(self.param.volatile.cls.predict_str(sents)) was the cause (took up 99% of the time). I will dive a bit more....not sure why this is slow...

It runs a classifier. Maybe check whether this classifier is on gpu?

from nast.

thangld201 avatar thangld201 commented on June 12, 2024

It runs a classifier. Maybe check whether this classifier is on gpu?

Yeah, you are right, self.param.volatile.cls.net was on cpu.

In NAST/styletransformer/run_cls.py, Line 47-69:

L47: parser.add_argument('--cuda', action="store_true", help='Use cuda (gpu).')
...
L69: args.cuda = "cuda" if cargs.cuda else "cpu"

since cargs was parsed from Line 64 in NAST/styletransformer/main.py i.e.
cls_param.args = run_cls.run("--dryrun", "--restore", args.clsrestore) # <----- do not have cuda flags

so I changed Line 64 to
cls_param.args = run_cls.run("--cuda", "--dryrun", "--restore", args.clsrestore)

And it worked! Validation now takes less than half a minute (Yelp)!
Thank you!

from nast.

Related Issues (7)

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.