Skip to content

Instantly share code, notes, and snippets.

@HarshTrivedi
HarshTrivedi / pad_packed_demo.py
Last active May 11, 2024 19:28 — forked from Tushar-N/pad_packed_demo.py
Minimal tutorial on packing (pack_padded_sequence) and unpacking (pad_packed_sequence) sequences in pytorch.
import torch
from torch import LongTensor
from torch.nn import Embedding, LSTM
from torch.autograd import Variable
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
## We want to run LSTM on a batch of 3 character sequences ['long_str', 'tiny', 'medium']
#
# Step 1: Construct Vocabulary
# Step 2: Load indexed data (list of instances, where each instance is list of character indices)
@okiriza
okiriza / example_autoencoder.py
Last active December 1, 2020 06:58
Example convolutional autoencoder implementation using PyTorch
import random
import torch
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import torchvision
from torchvision import datasets, transforms
@pannous
pannous / tensorflow_xor_hello_world.py
Created November 11, 2015 14:33
A simple neural network learning the XOR function with the tensorflow framework
#!/usr/bin/env PYTHONIOENCODING="utf-8" python
"""
A simple neural network learning the XOR function
"""
import tensorflow as tf
sess = tf.InteractiveSession()
# Desired input output mapping of XOR function:
x_ = [[0, 0], [0, 1], [1, 0], [1, 1]] # input
#labels=[0, 1, 1, 0] # output =>
@bsweger
bsweger / useful_pandas_snippets.md
Last active April 19, 2024 18:04
Useful Pandas Snippets

Useful Pandas Snippets

A personal diary of DataFrame munging over the years.

Data Types and Conversion

Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)

@meagar
meagar / rebase.md
Created April 30, 2014 16:01
Ultimate rebase-onto-master guide

Rebase "web-123-my-branch" onto master:

if you're the only person who is working on a branch...

$ git checkout web-123-my-branch # make sure you're on the right branch
$ git fetch # update remote refs
$ git rebase origin/master # perform the rebase onto the current state of master
  # for each conflict, edit file, resolve conflicts, git add -u <file>, git rebase --continue
$ git push -f origin web-123-my-branch # overwrite remote branch with newly rebase branch
@joemilbourn
joemilbourn / k-means-2d.ipynb
Created October 28, 2012 22:18
Example ipython notebook file with a simple k-means algorithm
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bwhite
bwhite / rank_metrics.py
Created September 15, 2012 03:23
Ranking Metrics
"""Information Retrieval metrics
Useful Resources:
http://www.cs.utexas.edu/~mooney/ir-course/slides/Evaluation.ppt
http://www.nii.ac.jp/TechReports/05-014E.pdf
http://www.stanford.edu/class/cs276/handouts/EvaluationNew-handout-6-per.pdf
http://hal.archives-ouvertes.fr/docs/00/72/67/60/PDF/07-busa-fekete.pdf
Learning to Rank for Information Retrieval (Tie-Yan Liu)
"""
import numpy as np
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 19, 2024 13:25
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname