Giter Club home page Giter Club logo

Comments (3)

pengzhiwang avatar pengzhiwang commented on July 27, 2024 1

Whether the code should be changed to the following form?


batch_size = int(hyperparams['batch'])
subdivisions = int(hyperparams['subdivisions'])
sub_batch = batch_size//subdivisions

.................

for epoch in range(opt.epochs):
for batch_i, (_, imgs, targets) in enumerate(dataloader):
imgs = Variable(imgs.type(Tensor))
targets = Variable(targets.type(Tensor), requires_grad=False)

    optimizer.zero_grad()
    for i in range(subdivisions):
        img = imgs[i*sub_batch:(i+1)*sub_batch]
        target = targets[i*sub_batch:(i+1)*sub_batch]
        loss = model(img, target)
        loss.backward()
        print('[Epoch %d/%d, Batch %d/%d] [Losses: x %f, y %f, w %f, h %f, conf %f, cls %f, total %f, recall: %.5f]' %
            (epoch, opt.epochs, batch_i, len(dataloader),
            model.losses['x'], model.losses['y'], model.losses['w'],
            model.losses['h'], model.losses['conf'], model.losses['cls'],
            loss.item(), model.losses['recall']))

    optimizer.step()
    model.seen += imgs.size(0)

if epoch % opt.checkpoint_interval == 0:
    model.save_weights('%s/%d.weights' % (opt.checkpoint_dir, epoch))

from pytorch-yolov3.

mark-hoffmann avatar mark-hoffmann commented on July 27, 2024 1

You don't need to create sub_batches, just simply lower your batch size and you should be fine. It essentially does the same thing and that's what that parameter is for.

from pytorch-yolov3.

pengzhiwang avatar pengzhiwang commented on July 27, 2024

Due to limited conditions, I can only use one GPU

from pytorch-yolov3.

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.