Skip to content

Instantly share code, notes, and snippets.

View sfujiwara's full-sized avatar

Shuhei Fujiwara sfujiwara

View GitHub Profile

この情報は 2014 年 のものなので, CPLEX のバージョンが上がった場合や, 環境が違う場合は適宜読み替えられたし.
IBM Academic Initiative についても変更があるかもしれないので気を付けられたし.

CPLEX のインストール

IBM Academic Initiative なるものに登録すると, 無償で使用することができる.
公式サイトがちょっとした迷宮になっているけど, 頑張って登録してダウンロードを済ませる.

IBM Academic Initiative に登録可能な条件がよくわからなかったので直接問い合わせたところ, 何らかの形で大学から給料を貰っていれば良いらしい.
額は関係ないので, ティーチングアシスタントで給料を貰っている学生ならば間違いなく大丈夫.

@sfujiwara
sfujiwara / cg.py
Created December 31, 2015 19:47
conjugate gradient method implemented with python
# -*- coding: utf-8 -*-
import numpy as np
from scipy.sparse.linalg import cg
import tensorflow as tf
import time
def conjugate_grad(A, b, x=None):
"""
# Description
# Hubot find palindrome.
#
# Dependencies:
# "kuromoji": "0.0.5"
#
# Configuration:
# None
#
# Author:
predictors = df_train.iloc[:,FEATURE_COLS].values
targets = df_train[TARGET_COL].values
shutil.rmtree('taxi_model', ignore_errors=True) # start fresh each time
modelprefix = 'taxi_model'
with tf.Session() as sess:
npredictors = len(FEATURE_COLS)
noutputs = 1
feature_data = tf.placeholder("float", [None, npredictors])
target_data = tf.placeholder("float", [None, noutputs])
hidden = tf.contrib.layers.stack(feature_data,
import numpy as np
import matplotlib.pyplot as plt
# Parameters used frequently
plt.rcParams['axes.labelsize'] = 24
plt.rcParams['lines.linewidth'] = 4
plt.rcParams['lines.markersize'] = 10
plt.rcParams['lines.markeredgewidth'] = 3
plt.rcParams['legend.fontsize'] = 18
plt.rcParams['legend.shadow'] = False
import tensorflow as tf
import optuna
import sklearn.datasets
from sklearn.model_selection import train_test_split
def create_input_fn():
iris = sklearn.datasets.load_iris()
x, y = iris.data, iris.target
x_train, x_eval, y_train, y_eval = train_test_split(x, y, test_size=0.5, random_state=42)
class TensorFlowPruningHook(tf.train.SessionRunHook):
def __init__(self, trial, estimator, metrics_name, is_higher_better, run_every_steps):
self.trial = trial
self.estimator = estimator
self.current_step = -1
self.metrics_name = metrics_name
self.is_higher_better = is_higher_better
self._global_step_tensor = None
self._timer = tf.train.SecondOrStepTimer(every_secs=None, every_steps=run_every_steps)
import tensorflow as tf
import optuna
import sklearn.datasets
from sklearn.model_selection import train_test_split
class TensorFlowPruningHook(tf.train.SessionRunHook):
def __init__(self, trial, estimator, metric, is_higher_better, run_every_steps):
self.trial = trial
import sys
import matplotlib.pyplot as plt
import numpy as np
import scipy as sp
from scipy.spatial import distance_matrix
from scipy.optimize import linear_sum_assignment
sys.setrecursionlimit(1000)
BIG_M = 1e5