This file contains 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
class RingBuffer: | |
def __init__(self, scope_name, components, size): | |
""" | |
Create a new ring buffer of size `size`. | |
Each item in the ring buffer is a tuple of variables of size `len(components)`. | |
:param scope_name: A scope name for the newly created variables | |
:param components: Defines the type of items in the buffer. An iterable of tuples (name: str, shape: Iterable, dtype) | |
:param size: The maximum size of the buffer |
This file contains 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 | |
import torch.nn as nn | |
import torch.nn.functional as F | |
import torchvision.models as tmodels | |
from functools import partial | |
import collections | |
# dummy data: 10 batches of images with batch size 16 | |
dataset = [torch.rand(16,3,224,224).cuda() for _ in range(10)] |