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 recursive_setattr(obj, name, value): | |
if '.' in name: | |
parent, child = name.split('.')[0], '.'.join(name.split('.')[1:]) | |
recursive_setattr(getattr(obj, parent), child, value) | |
else: | |
setattr(obj, name, value) |
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
""" Argparser to wandb query. | |
References | |
---------- | |
Short tutorial: https://docs.wandb.ai/ref/export-api | |
Wandb API: https://docs.wandb.ai/ref/export-api/api | |
- Api.runs | |
- RUN class | |
Mongodb query: https://docs.mongodb.com/manual/reference/operator/query/ | |
""" |
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 MLPEncoder(nn.Module): | |
def __init__(self): | |
super(MLPEncoder, self).__init__() | |
# TODO: Fix hard coding | |
self.model = nn.Sequential(OrderedDict([ | |
('layer1', nn.Linear(784, 400)), | |
('relu1', nn.ReLU()), | |
('layer2', nn.Linear(400, 400)), | |
('relu2', nn.ReLU()), |
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
# # -*- coding: utf-8 -*- | |
import itertools | |
from torch.utils import data | |
def l2diff(x1, x2): | |
""" | |
standard euclidean norm | |
""" | |
return ((x1-x2)**2).sum().sqrt() |
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
# # -*- coding: utf-8 -*- | |
"""Utils to handle saved information in mongodb.""" | |
from future.utils import iteritems | |
import pandas as pd | |
from pymongo import MongoClient | |
def expand_config(config): |
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 keras.backend as K | |
import numpy as np | |
from keras.layers import Input, Dense, Lambda, Activation | |
from keras.models import Model | |
def temped_softmax(x, T=1): | |
"""Compute softmax values for each sets of scores in x.""" | |
return np.exp(x/T) / np.sum(np.exp(x/T), axis=0) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder