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 itertools import product | |
import torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
from torch import autograd | |
from torch.autograd.function import once_differentiable | |
class my_func(autograd.Function): | |
@staticmethod | |
def forward(ctx, x, scale=2.0): |
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
'''ResNet in PyTorch. | |
For Pre-activation ResNet, see 'preact_resnet.py'. | |
Reference: | |
[1] Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun | |
Deep Residual Learning for Image Recognition. arXiv:1512.03385 | |
''' | |
import torch | |
import torch.nn as nn |
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
'''ResNet in PyTorch. | |
For Pre-activation ResNet, see 'preact_resnet.py'. | |
Reference: | |
[1] Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun | |
Deep Residual Learning for Image Recognition. arXiv:1512.03385 | |
''' | |
import torch | |
import torch.nn as nn |
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 math | |
import os | |
import nvidia.dali.ops as ops | |
import nvidia.dali.types as types | |
import nvidia.dali.tfrecord as tfrec | |
from nvidia.dali.backend import oss | |
from nvidia.dali.pipeline import Pipeline | |
from nvidia.dali.plugin.pytorch import DALIGenericIterator, DALIClassificationIterator | |
from nvidia.dali.types import DALIDataType |
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
Sample::Sample(){ | |
LOG(INFO) << "Initializing model"; | |
struct timeval begint, endt; | |
gettimeofday(&begint, NULL); | |
TF_Buffer* graph_def = read_file("./models.pb"); | |
tf_graph_ = TF_NewGraph(); | |
// Import graph_def into graph | |
TF_Status* status = TF_NewStatus(); | |
TF_ImportGraphDefOptions* opts = TF_NewImportGraphDefOptions(); | |
TF_GraphImportGraphDef(tf_graph_, graph_def, opts, status); |
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
name: "CaffeNet" | |
layer { | |
name: "input" | |
type: "Input" | |
top: "data" | |
input_param { | |
shape { | |
dim: 1 | |
dim: 3 |
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 <algorithm> | |
#include <vector> | |
#include "caffe/layers/relu_layer.hpp" | |
namespace caffe { | |
template <typename Dtype> | |
__global__ void ReLUForward(const int n, const Dtype* in, Dtype* out, | |
Dtype negative_slope, Dtype threshold) { |
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 "caffe/layers/regression_accuracy_layer.hpp" | |
namespace caffe{ | |
template <typename Dtype> | |
void RegressionAccuracyLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom, | |
const vector<Blob<Dtype>*>& top){ | |
vector<int> top_shape(0); // Accuracy is a scalar; 0 axes. | |
top[0]->Reshape(top_shape); | |
} | |
template <typename Dtype> |