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 gc | |
import numpy as np | |
import sys | |
import time | |
import torch | |
from torch.autograd import Variable | |
import torchvision.models as models | |
import torch.backends.cudnn as cudnn | |
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.nn as nn | |
class SequentialSG(nn.Sequential): | |
def accGradParameters(self, input, gradOutput, scale=1): | |
currentGradOutput = gradOutput | |
currentModule = self.modules[-1] | |
for i in range(len(self.modules)-1, 0, -1): | |
previousModule = self.modules[i] | |
if currentModule.__class__.name == 'ErrorFeedback': |
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.autograd import Function, Variable | |
class ErrorFeedbackFunction(Function): | |
# the forward pass consists in copying the input to the output | |
@staticmethod | |
def forward(ctx, input, feedback): | |
ctx.save_for_backward(input, feedback) | |
return input |
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
from FunctionErrorFeedback import ErrorFeedbackFunction | |
from torch.autograd import Function, Variable | |
import torch | |
import torch.nn as nn | |
class EF(nn.Module): | |
def __init__(self, layer_dim, error_dim): | |
super(EF, self).__init__() | |
self.feedback = torch.Tensor(error_dim, layer_dim) |
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
from __future__ import print_function, division | |
import math | |
import torch | |
from torch.autograd import Function, Variable | |
import torch.nn as nn | |
import torch.nn.functional as F | |
from ErrorFeedback import EF | |
from FunctionErrorFeedback import ErrorFeedbackFunction | |
from SequentialSG import SequentialSG |
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
from torchvision.datasets import MNIST | |
import torchvision.transforms as transforms | |
import torch | |
import torch.legacy.nn as lnn | |
import torch.legacy.optim as loptim | |
train_dataset = MNIST(root='./data', | |
train=True, | |
transform=transforms.ToTensor(), |
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
from time import time | |
import torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
class ConvNetV0(nn.Module): | |
def __init__(self): | |
super(ConvNetV0, self).__init__() |
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
#include <torch/extension.h> | |
#include <cmath> | |
#include <iostream> | |
#include <vector> | |
at::Tensor ex_forward( | |
at::Tensor input | |
) { | |
auto n_samples = input.size(0); |
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 os | |
import ray | |
from ray import tune | |
import torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
import torch.optim as optim | |
from torch.utils.data import DataLoader, TensorDataset |
OlderNewer