start new:
tmux
start new with session name:
tmux new -s myname
# coding: utf-8 | |
import logging | |
import re | |
from collections import Counter | |
import numpy as np | |
import torch | |
from sklearn.datasets import fetch_20newsgroups | |
from torch.autograd import Variable |
In this article, I will share some of my experience on installing NVIDIA driver and CUDA on Linux OS. Here I mainly use Ubuntu as example. Comments for CentOS/Fedora are also provided as much as I can.
#A Collection of NLP notes
##N-grams
###Calculating unigram probabilities:
P( wi ) = count ( wi ) ) / count ( total number of words )
In english..
def _sequence_mask(sequence_length, max_len=None): | |
if max_len is None: | |
max_len = sequence_length.data.max() | |
batch_size = sequence_length.size(0) | |
seq_range = torch.range(0, max_len - 1).long() | |
seq_range_expand = seq_range.unsqueeze(0).expand(batch_size, max_len) | |
seq_range_expand = Variable(seq_range_expand) | |
if sequence_length.is_cuda: | |
seq_range_expand = seq_range_expand.cuda() | |
seq_length_expand = (sequence_length.unsqueeze(1) |
class AttentionLSTM(LSTM): | |
"""LSTM with attention mechanism | |
This is an LSTM incorporating an attention mechanism into its hidden states. | |
Currently, the context vector calculated from the attended vector is fed | |
into the model's internal states, closely following the model by Xu et al. | |
(2016, Sec. 3.1.2), using a soft attention model following | |
Bahdanau et al. (2014). | |
The layer expects two inputs instead of the usual one: |
#!/usr/bin/env python | |
import signal | |
import sys | |
def signal_handler(signal, frame): | |
sys.exit(0) | |
signal.signal(signal.SIGINT, signal_handler) |
#! /usr/bin/env python | |
""" | |
Author: Jeremy M. Stober | |
Program: SOFTMAX.PY | |
Date: Wednesday, February 29 2012 | |
Description: Simple softmax function. | |
""" | |
import numpy as np | |
npa = np.array |
git add HISTORY.md
git commit -m "Changelog for upcoming release 0.1.1."
bumpversion patch
from sshtunnel import SSHTunnelForwarder | |
import pymongo | |
MONGO_HOST = "IP_ADDRESS" | |
MONGO_USER = "USERNAME" | |
MONGO_PASS = "PASSWORD" | |
MONGO_DB = "DATABASE_NAME" | |
MONGO_COLLECTION = "COLLECTION_NAME" | |
# define ssh tunnel |