Example #1
0
def get_simclr_transform(size, s=1):
    """Return a set of data augmentation transformations as described in the SimCLR paper."""
    color_jitter = transforms.ColorJitter(0.8 * s, 0.8 * s, 0.8 * s, 0.2 * s)
    data_transforms = transforms.Compose([
        transforms.Resize(size=size),
        transforms.RandomHorizontalFlip(),
        transforms.RandomApply([color_jitter], p=0.8),
        transforms.RandomGrayscale(p=0.2),
        GaussianBlur(kernel_size=int(0.1 * size)),
        transforms.ToTensor(),
        transforms.Normalize(mean=(0.485, 0.456, 0.406),
                             std=(0.229, 0.224, 0.225))
    ])
    return data_transforms
Example #2
0
    def _simclr_transform(self):
        ### TODO: Complete SimCLR transforms ###
        # I strongly recommand you to use torchvision.transforms to implement data augmentation
        # You can use provided gaussian_blur if you want

        random_resized_crop = transforms.RandomResizedCrop(size=(96, 96))
        random_horizontal_flip = transforms.RandomHorizontalFlip()
        color_distortion = ColorDistortion()
        gaussian_blur = GaussianBlur(kernel_size=int(0.1 *
                                                     self.input_shape[0]))

        data_transforms = transforms.Compose([
            random_resized_crop, random_horizontal_flip, color_distortion,
            gaussian_blur,
            transforms.ToTensor(),
            transforms.Normalize(mean=[0.485, 0.456, 0.406],
                                 std=[0.229, 0.224, 0.225])
        ])

        return data_transforms
Example #3
0
# It's a good idea to try to keep your bots deterministic, to make debugging easier.
# determinism isn't required, but it means that the same things will happen in every thing you run,
# aside from turns taking slightly different amounts of time due to noise.
random.seed(6137)

# let's start off with some research!
# we can queue as much as we want.

gc.queue_research(bc.UnitType.Knight)
gc.queue_research(bc.UnitType.Rocket)
#gc.queue_research(bc.UnitType.Ranger)
gc.queue_research(bc.UnitType.Worker)


my_team = gc.team()
gb = GaussianBlur(gc)
gd = gb.get_gauss()
rocket_id = -1
unit_rocket = 0
while True:
    # We only support Python 3, which means brackets around print()
    print('pyround:', gc.round(), 'time left:', gc.get_time_left_ms(), 'karbonite:', gc.karbonite(), 'ms')

    # frequent try/catches are a good idea
    try:
        # walk through our units:
        for unit in gc.my_units():
            move = 0;
            # first, factory logic
            if unit.unit_type == bc.UnitType.Factory:
                garrison = unit.structure_garrison()