Skip to content

Instantly share code, notes, and snippets.

View fly51fly's full-sized avatar

爱可可-爱生活 fly51fly

View GitHub Profile
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.
@ledell
ledell / DeepThings_on_aRxiv.R
Last active February 2, 2021 21:13
A list of papers on arxiv.org with the over-hyped Deep* prefix in the title.
# https://ropensci.org/tutorials/arxiv_tutorial.html
install.packages("aRxiv")
library(aRxiv)
library(stringr)
library(ggplot2)
# Query arxiv: 6892 results including "Deep"; 49 DeepThings (Sept 21, 2017)
df <- arxiv_search('ti:"Deep"', batchsize = 1000, limit = 100000)
titles <- grep(pattern = "Deep[[:upper:]][[:lower:]]+",
@fchollet
fchollet / new_stacked_rnns.py
Last active August 13, 2019 15:23
New stacked RNNs in Keras
import keras
import numpy as np
timesteps = 60
input_dim = 64
samples = 10000
batch_size = 128
output_dim = 64
# Test data.
@eamartin
eamartin / notebook.ipynb
Last active April 22, 2025 08:11
Understanding & Visualizing Self-Normalizing Neural Networks
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nasimrahaman
nasimrahaman / weighted_cross_entropy.py
Last active November 16, 2023 04:54
Pytorch instance-wise weighted cross-entropy loss
import torch
import torch.nn as nn
def log_sum_exp(x):
# See implementation detail in
# http://timvieira.github.io/blog/post/2014/02/11/exp-normalize-trick/
# b is a shift factor. see link.
# x.size() = [N, C]:
b, _ = torch.max(x, 1)
@minhlab
minhlab / sanity-check.py
Last active July 17, 2017 07:48
Testing the validity of sanity check proposed in Batchkarov et al. (2016)
import numpy as np
from scipy.stats import spearmanr, pearsonr
from matplotlib import pyplot as pl
import sys
if __name__ == '__main__':
repeats = int(sys.argv[1]) if len(sys.argv) >= 2 else 5 # change this and see what happens
dim = 50
#sizes = {'simlex': 999, 'men': 3000, 'mc': 30, 'rg': 65, 'ws353': 353}
sizes = {'men': (3000, '#0066ff', '#4d94ff'), 'mc': (30, '#ff3300', '#ffd6cc80'), 'rg': (65, '#00ff00', '#ccffcc80')}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

A Tour of PyTorch Internals (Part I)

The fundamental unit in PyTorch is the Tensor. This post will serve as an overview for how we implement Tensors in PyTorch, such that the user can interact with it from the Python shell. In particular, we want to answer four main questions:

  1. How does PyTorch extend the Python interpreter to define a Tensor type that can be manipulated from Python code?
  2. How does PyTorch wrap the C libraries that actually define the Tensor's properties and methods?
  3. How does PyTorch cwrap work to generate code for Tensor methods?
  4. How does PyTorch's build system take all of these components to compile and generate a workable application?

Extending the Python Interpreter

PyTorch defines a new package torch. In this post we will consider the ._C module. This module is known as an "extension module" - a Python module written in C. Such modules allow us to define new built-in object types (e.g. the Tensor) and to call C/C++ functions.

@kylemcdonald
kylemcdonald / t-SNE Implementation Comparison.ipynb
Last active December 20, 2017 01:47
Comparison of different t-SNE implementations for speed and results.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.