NVIDIA / NVIDIA/apex

FP16 about input and loss?

Open
#87 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
9k
Forks
1.5k
Avg merge
2d 4h
Merged PRs (30d)
3

Description

I have two questions about how to train the network correctly with fp16?

First, In main_fp16_optimizer.py, input will be .half() in data_prefetcher(), and model = network_to_half(model). Should input.half be necessary? #58

train_dataset = datasets.ImageFolder(
        traindir,
        transforms.Compose([
            transforms.RandomResizedCrop(crop_size),
            transforms.RandomHorizontalFlip(),
            # transforms.ToTensor(), Too slow
            # normalize,
        ]))

Second, should we concern about the operation in the criterion (loss function), which may be more complicated such as the loss function in object detection and sementation ?

if args.fp16:
            optimizer.backward(loss)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with main_fp16_optimizer.py, data_prefetcher(), network_to_half(model), and the optimizer.backward(loss) call. Determine from the existing training flow how input and criterion operations are expected to handle fp16, then document clear guidance for standard and more complex losses; done means both questions have an unambiguous usage answer.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.