This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from allennlp.data.tokenizers.token_class import Token | |
from allennlp.data.tokenizers.tokenizer import Tokenizer | |
from fugashi import Tagger | |
@Tokenizer.register("mecab") | |
class MecabTokenizer(Tokenizer): | |
def __init__(self): | |
# Taggerインスタンスを作成 | |
self._tagger = Tagger() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import json | |
import os | |
import torch | |
from transformers import LukeConfig, LukeForEntityPairClassification, LukeTokenizer, RobertaTokenizer | |
from transformers.tokenization_utils_base import AddedToken | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import deepspeed | |
from transformers import BertLayer, BertConfig | |
hf_config = BertConfig() | |
hf_layer = BertLayer(hf_config) | |
hf_layer.eval().to("cuda") | |
ds_config = deepspeed.DeepSpeedTransformerConfig( | |
batch_size=16, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
ec2_spot_price_list.py - Display the price summary of AWS EC2's spot instances across all regions | |
and availability zones. | |
Basic usage: | |
$ pip install numpy click boto3 | |
$ python ec2_spot_price_list.py --instance-type m5.xlarge --product-description "Linux/UNIX (Amazon VPC)" | |
Copyright (C) 2019, Ikuya Yamada |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from multiprocessing import Pool | |
from itertools import islice | |
def imap_lazy(func, iterable, pool_size=10, chunk_size=10000, | |
maxtasksperchild=1000, unordered=False): | |
p = Pool(processes=pool_size, maxtasksperchild=maxtasksperchild) | |
while True: | |
chunk = list(islice(iterable, chunk_size)) | |
if not chunk: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import base64 | |
import cPickle as pickle | |
import hashlib | |
from functools import wraps | |
class NoopSerializer(object): | |
def serialize(self, obj): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ITERM_SESSION_NAME=Default | |
if [ $TERM_PROGRAM = "iTerm.app" ]; then | |
function new_tab() { | |
osascript\ | |
-e "tell application \"iTerm\""\ | |
-e "tell the first terminal"\ | |
-e "launch session \"${ITERM_SESSION_NAME}\""\ | |
-e "tell the current session"\ | |
-e "write text \"$1\""\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from libcpp.utility cimport pair | |
cdef extern from "<tr1/unordered_map>" namespace "std::tr1": | |
cdef cppclass unordered_map[T, U]: | |
cppclass iterator: | |
pair[T, U]& operator*() nogil | |
iterator operator++() nogil | |
iterator operator--() nogil | |
bint operator==(iterator) nogil | |
bint operator!=(iterator) nogil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var TWITTER_USER_NAME = 'ikuyamada'; | |
function processTweets(data) { | |
var urls = []; | |
for (var i = 0; i < data.length; i++) { | |
var ret = data[i].text.match(/https?:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+/); | |
if (ret) | |
urls = urls.concat(ret); | |
} | |
showUrlList(urls); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export LANG=ja_JP.UTF-8 | |
export MAILCHECK=0 | |
export EDITOR=vim | |
HISTFILE=$HOME/.zsh-history | |
HISTSIZE=3000 | |
SAVEHIST=3000 | |
PROMPT="%B%n@%m%%%b " | |
RPROMPT="%B[%~]%b" |
NewerOlder