Skip to content

Instantly share code, notes, and snippets.

View sazio's full-sized avatar
🚀
Focusing

Simone Azeglio sazio

🚀
Focusing
View GitHub Profile
@khannay
khannay / part_01.py
Created April 17, 2023 00:51
Differential Equations as a Pytorch Neural Network Layer
#| export
import torch
import torch.nn as nn
from torchdiffeq import odeint_adjoint as odeint
import pylab as plt
from torch.utils.data import Dataset, DataLoader
from typing import Callable, List, Tuple, Union, Optional
@kmhofmann
kmhofmann / installing_nvidia_driver_cuda_cudnn_linux.md
Last active June 11, 2024 09:29
Installing the NVIDIA driver, CUDA and cuDNN on Linux

Installing the NVIDIA driver, CUDA and cuDNN on Linux (Ubuntu 20.04)

This is a companion piece to my instructions on building TensorFlow from source. In particular, the aim is to install the following pieces of software

on an Ubuntu Linux system, in particular Ubuntu 20.04.

@vadimkantorov
vadimkantorov / lowrank_bilinear_pooling.py
Last active May 18, 2023 15:58
Low Rank Bilinear Pooling implementation in PyTorch
# Hadamard Product for Low-Rank Bilinear Pooling, Kim et al., https://arxiv.org/abs/1610.04325
# Original implementation in LuaTorch: https://github.com/jnhwkim/MulLowBiVQA
import torch
class LowRankBilinearPooling(torch.nn.Module):
def __init__(self, in_channels1, in_channels2, hidden_dim, out_channels, nonlinearity = torch.nn.Identity, sum_pool = True):
super().__init__()
self.nonlinearity = nonlinearity
self.sum_pool = sum_pool
@lmcinnes
lmcinnes / AlignedUMAP Demo.ipynb
Created April 7, 2020 18:50
Demonstration of experimental Aligned UMAP in 0.5dev
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ChrisRackauckas
ChrisRackauckas / diffeqflux_differentialequations_vs_torchdiffeq_results.md
Last active July 19, 2024 01:24
torchdiffeq (Python) vs DifferentialEquations.jl (Julia) ODE Benchmarks (Neural ODE Solvers)

Torchdiffeq vs DifferentialEquations.jl (/ DiffEqFlux.jl) Neural ODE Compatible Solver Benchmarks

Only non-stiff ODE solvers are tested since torchdiffeq does not have methods for stiff ODEs. The ODEs are chosen to be representative of models seen in physics and model-informed drug development (MIDD) studies (quantiative systems pharmacology) in order to capture the performance on realistic scenarios.

Summary

Below are the timings relative to the fastest method (lower is better). For approximately 1 million ODEs and less, torchdiffeq was more than an order of magnitude slower than DifferentialEquations.jl

@vadimkantorov
vadimkantorov / perlin.py
Last active February 15, 2024 10:36
Perlin noise in PyTorch
# ported from https://github.com/pvigier/perlin-numpy/blob/master/perlin2d.py
import torch
import math
def rand_perlin_2d(shape, res, fade = lambda t: 6*t**5 - 15*t**4 + 10*t**3):
delta = (res[0] / shape[0], res[1] / shape[1])
d = (shape[0] // res[0], shape[1] // res[1])
grid = torch.stack(torch.meshgrid(torch.arange(0, res[0], delta[0]), torch.arange(0, res[1], delta[1])), dim = -1) % 1
@williamFalcon
williamFalcon / Pytorch_LSTM_variable_mini_batches.py
Last active April 24, 2024 17:53
Simple batched PyTorch LSTM
import torch
import torch.nn as nn
from torch.autograd import Variable
from torch.nn import functional as F
"""
Blog post:
Taming LSTMs: Variable-sized mini-batches and why PyTorch is good for your health:
https://medium.com/@_willfalcon/taming-lstms-variable-sized-mini-batches-and-why-pytorch-is-good-for-your-health-61d35642972e
"""
@BIGBALLON
BIGBALLON / extract_ILSVRC.sh
Created May 13, 2018 20:09
script for ImageNet data extract.
#!/bin/bash
#
# script to extract ImageNet dataset
# ILSVRC2012_img_train.tar (about 138 GB)
# ILSVRC2012_img_val.tar (about 6.3 GB)
# make sure ILSVRC2012_img_train.tar & ILSVRC2012_img_val.tar in your current directory
#
# https://github.com/facebook/fb.resnet.torch/blob/master/INSTALL.md
#
# train/
@dadaromeo
dadaromeo / Conway-Maxwell-Poisson distribution.ipynb
Last active June 17, 2024 15:41
Implementation of the Conway-Maxwell-Poisson distribution in pymc3
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wangruohui
wangruohui / Install NVIDIA Driver and CUDA.md
Last active June 29, 2024 09:06
Install NVIDIA Driver and CUDA on Ubuntu / CentOS / Fedora Linux OS