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
# fixed version of http://altons.github.io/python/2012/12/01/converting-northing-and-easting-to-latitude-and-longitude/ | |
# - filenames | |
# - data type (pyproj transform doesn't like pandas series) | |
import os | |
import pandas as pd | |
import pyproj | |
import re | |
listfiles = os.listdir("codepo/Data/CSV") | |
pieces = [] |
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
""" | |
Create train, valid, test iterators for CIFAR-10 [1]. | |
Easily extended to MNIST, CIFAR-100 and Imagenet. | |
[1]: https://discuss.pytorch.org/t/feedback-on-pytorch-for-kaggle-competitions/2252/4 | |
""" | |
import torch | |
import numpy as np |
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
def lossless_triplet_loss(y_true, y_pred, N = 3, beta=N, epsilon=1e-8): | |
""" | |
Implementation of the triplet loss function | |
Arguments: | |
y_true -- true labels, required when you define a loss in Keras, you don't need it in this function. | |
y_pred -- python list containing three objects: | |
anchor -- the encodings for the anchor data | |
positive -- the encodings for the positive data (similar to anchor) | |
negative -- the encodings for the negative data (different from anchor) |
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
def get_texts(path): | |
rows_list = [] | |
for idx, label in enumerate(CLASSES): | |
print(f'working on {path}/{label}') | |
for fname in (path/f'{label}').glob('*.*'): | |
dict1 = {} | |
text = fname.open('r').read() | |
dict1.update({ | |
'text':text, | |
'label':idx |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 | |
from torch import nn, optim | |
class Constraint(nn.Module): | |
def __init__(self, fn, maximum, damping=1e-2): | |
super().__init__() | |
self.fn = fn | |
self.register_buffer('maximum', torch.as_tensor(maximum)) | |
self.register_buffer('damping', torch.as_tensor(damping)) |
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
"""Trains IMLE on the MNIST dataset.""" | |
import torch | |
from torch import optim, nn | |
from torch.nn import functional as F | |
from torch.utils import data | |
from torchvision import datasets, transforms, utils | |
from torchvision.transforms import functional as TF | |
from tqdm import tqdm |
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
#!/usr/bin/env python3 | |
import argparse | |
from collections import defaultdict | |
import csv | |
import math | |
import torch | |
from torch import nn, optim | |
from torch.nn import functional as F |
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
# Modified StyleGAN2 Projector with CLIP, addl. losses, kmeans, etc. | |
# by Peter Baylies, 2021 -- @pbaylies on Twitter | |
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. | |
# | |
# NVIDIA CORPORATION and its licensors retain all intellectual property | |
# and proprietary rights in and to this software, related documentation | |
# and any modifications thereto. Any use, reproduction, disclosure or | |
# distribution of this software and related documentation without an express | |
# license agreement from NVIDIA CORPORATION is strictly prohibited. |
OlderNewer