Skip to content

Instantly share code, notes, and snippets.

@rwightman
rwightman / timm_unet.py
Created April 15, 2021 19:12
An example U-Net using timm features_only functionality.
""" A simple U-Net w/ timm backbone encoder
Based off an old version of Unet in https://github.com/qubvel/segmentation_models.pytorch
Hacked together by Ross Wightman
"""
from typing import Optional, List
import torch
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alimanfoo
alimanfoo / find_runs.py
Created November 5, 2017 23:53
Find runs of consecutive items in a numpy array.
import numpy as np
def find_runs(x):
"""Find runs of consecutive items in an array."""
# ensure array
x = np.asanyarray(x)
if x.ndim != 1:
raise ValueError('only 1D array supported')
@jkleint
jkleint / timeseries_cnn.py
Created July 29, 2016 04:05
Example of using Keras to implement a 1D convolutional neural network (CNN) for timeseries prediction.
#!/usr/bin/env python
"""
Example of using Keras to implement a 1D convolutional neural network (CNN) for timeseries prediction.
"""
from __future__ import print_function, division
import numpy as np
from keras.layers import Convolution1D, Dense, MaxPooling1D, Flatten
from keras.models import Sequential
@karpathy
karpathy / min-char-rnn.py
Last active November 17, 2024 20:43
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@rogerallen
rogerallen / country_abbrev.py
Last active October 9, 2024 14:34
A Python Dictionary to translate Country Names to Two letter codes
# Python Dictionary to translate Countries to Two-Letter codes and vice versa.
#
# https://gist.github.com/rogerallen/1583606
#
# Dedicated to the public domain. To the extent possible under law,
# Roger Allen has waived all copyright and related or neighboring
# rights to this code. Data originally from Wikipedia at the url:
# https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
#
# Automatically Generated 2024-10-08 07:45:05 via Jupyter Notebook from