Skip to content

Instantly share code, notes, and snippets.

View t-abe's full-sized avatar

Takashi Abe t-abe

  • Preferred Networks, Inc.
  • Tokyo, Japan
View GitHub Profile
@t-abe
t-abe / cfr.py
Created November 20, 2019 13:02
import numpy as np
import typing
from collections import OrderedDict, Callable
import random
from copy import copy
import time
class Node(object):
def __init__(self, prev=None, action=(), player=None):
#!/bin/bash
# (c) Wolfgang Ziegler // fago
#
# Inotify script to trigger a command on file changes.
#
# The script triggers the command as soon as a file event occurs. Events
# occurring during command execution are aggregated and trigger a single command
# execution only.
#
# Usage example: Trigger rsync for synchronizing file changes.
import urllib.request
import lxml.html as html
target_url = 'https://headlines.yahoo.co.jp/hl?a=20171227-00000094-dal-base'
req = urllib.request.urlopen(target_url)
tree = html.parse(req)
r = tree.xpath('//*[@id="ym_newsarticle"]/div[2]/div[1]/p')
print(r[0].text_content())
@t-abe
t-abe / computational_cost_hook.py
Created April 28, 2017 09:14
Hook implementation to calculate roughly estimated computational cost of a given network for Chainer
from __future__ import print_function
import sys
import chainer
from chainer.utils import conv
class ComputationalCostHook(chainer.function.FunctionHook):
name = 'ComputationalCostHook'
class ForgetVariable(chainer.Variable):
data_cache = None
last_accessed_id = None
def __init__(self, x):
"""
:type x: chainer.Variable
"""
self.rank = x.rank
self._volatile = x._volatile
#! /bin/bash
mkdir opencv_src
cd opencv_src
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git
cd opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=$HOME/.local -D WITH_TBB=ON -D WITH_EIGEN=OFF -D WITH_FFMPEG=ON -D WITH_QT=OFF -DWITH_CUDA=ON -DWITH_OPENCL=OFF -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules ..
make -j4
class A(object):
def __init__(self, ar = []):
self.ar = ar
a = A()
b = A()
a.ar.append(1)
b.ar.append(2)
print a.ar # => [1, 2]
#include <iostream>
#include <string>
#include <fstream>
#include "../third_party/cmdline/cmdline.h"
#include "../common/exception.hpp"
#include "../storage/local_storage.hpp"
using std::vector;
using std::pair;
using jubatus::storage::local_storage;
@t-abe
t-abe / emacs.rb
Last active December 14, 2015 10:10 — forked from rfkm/emacs.rb
require 'formula'
class Emacs < Formula
homepage 'http://www.gnu.org/software/emacs/'
url 'http://ftp.yz.yamagata-u.ac.jp/pub/GNU/emacs/emacs-24.2.tar.gz'
sha1 '5fc4fe7797f821f2021ac415a81f5f190c52c0b2'
depends_on "autoconf" => :build
if ARGV.include? "--use-git-head"
@t-abe
t-abe / pls.hpp
Created July 10, 2011 10:27
Partial Least Squares
/********
// Multi-class
const int N; // number of samples
const int D; // dimension of feature
const int M; // number of classes
const int P; // number of reduced domensions
double* X = new double[D * N]; // features
double* Y = new double[M * N]; // labels
double* W = new double[D * P]; // projection matrix