ca078e83147f95ec7df149ef5eea9b6a8424d3bf,memcnn/models/tests/test_memory_saving.py,,test_memory_saving,#,199

Before Change


    network.to(device)
    network.train()
    network.zero_grad()
    optim = torch.optim.RMSprop(network.parameters())
    optim.zero_grad()
    mem_start = 0 if not device == "cuda" else \
        torch.cuda.memory_allocated() / float(1024 ** 2)

    y = network(xx)
    gc.collect()
    mem_after_forward = mem_reporter.collect_stats() / float(1024 ** 2) if not device == "cuda" else \
        torch.cuda.memory_allocated() / float(1024 ** 2)
    loss = torch.nn.MSELoss()(y, ytarget)
    optim.zero_grad()
    loss.backward()
    optim.step()
    gc.collect()
    // mem_after_backward = mem_reporter.collect_stats() / float(1024 ** 2) if not device == "cuda" else \
    //     torch.cuda.memory_allocated() / float(1024 ** 2)
    gc.enable()

After Change


        network.to(device)
        network.train()
        network.zero_grad()
        optim = torch.optim.RMSprop(network.parameters())
        optim.zero_grad()
        mem_start = 0 if not device == "cuda" else \
            torch.cuda.memory_allocated() / float(1024 ** 2)

        y = network(xx)
        gc.collect()
        mem_after_forward = mem_reporter.collect_stats() / float(1024 ** 2) if not device == "cuda" else \
            torch.cuda.memory_allocated() / float(1024 ** 2)
        loss = torch.nn.MSELoss()(y, ytarget)
        optim.zero_grad()
        loss.backward()
        optim.step()
        gc.collect()
        // mem_after_backward = mem_reporter.collect_stats() / float(1024 ** 2) if not device == "cuda" else \
        //     torch.cuda.memory_allocated() / float(1024 ** 2)
        gc.enable()
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: silvandeleemput/memcnn
Commit Name: ca078e83147f95ec7df149ef5eea9b6a8424d3bf
Time: 2019-12-12
Author: silvandeleemput@gmail.com
File Name: memcnn/models/tests/test_memory_saving.py
Class Name:
Method Name: test_memory_saving


Project Name: eriklindernoren/PyTorch-YOLOv3
Commit Name: 2ee8ac1546400645908b61ef015cdf5d71aa34cc
Time: 2019-04-22
Author: eriklindernoren@live.se
File Name: train.py
Class Name:
Method Name:


Project Name: silvandeleemput/memcnn
Commit Name: 85426e4964fb6ee30ca5b14c5c79f4843e948962
Time: 2019-12-12
Author: silvandeleemput@gmail.com
File Name: memcnn/models/tests/test_revop.py
Class Name:
Method Name: test_revblock_chained