This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch.utils.data | |
from torchvision import datasets, transforms | |
class PartialDataset(torch.utils.data.Dataset): | |
def __init__(self, parent_ds, offset, length): | |
self.parent_ds = parent_ds | |
self.offset = offset | |
self.length = length | |
assert len(parent_ds)>=offset+length, Exception("Parent Dataset not long enough") | |
super(PartialDataset, self).__init__() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import torch | |
from torch.autograd import Variable | |
import torch.nn as nn | |
import gc | |
# helper function to get rss size, see stat(5) under statm. This is in pages (4k on my linux) | |
def memory_usage(): | |
return int(open('/proc/self/statm').read().split()[1]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is taken from https://github.com/yunjey/pytorch-tutorial with just a few changes. | |
# Please see there for copyright and license information and use that copy. | |
import torch | |
import torch.nn as nn | |
import torchvision.datasets as dsets | |
import torchvision.transforms as transforms | |
from torch.autograd import Variable | |
import gc |
NewerOlder