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 numpy as np | |
import tensorflow as tf | |
from numpy.random import RandomState | |
from sklearn.model_selection import StratifiedShuffleSplit | |
from tensorflow.contrib.layers import fully_connected | |
tf.logging.set_verbosity(tf.logging.INFO) | |
random_state = RandomState() |
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 tensorflow as tf | |
tf.app.flags.DEFINE_string('ps_hosts', '', 'Comma-separated list of hostname:port pairs') | |
tf.app.flags.DEFINE_string('worker_hosts', '', 'Comma-separated list of hostname:port pairs') | |
tf.app.flags.DEFINE_string('job_name', '', 'One of ps or worker') | |
tf.app.flags.DEFINE_integer('task_index', 0, 'Index of task within the job') | |
tf.app.flags.DEFINE_string('logdir', 'logdir', 'Directory to log') | |
FLAGS = tf.app.flags.FLAGS |
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 functools import reduce | |
from typing import List | |
from typing import Set | |
from selenium.common.exceptions import NoSuchElementException | |
from selenium.webdriver import Chrome | |
URLs = [ | |
r'https://scholar.google.com/scholar?cites=17690265189765140803&as_sdt=2005&sciodt=0,5&hl=ja', | |
r'https://scholar.google.com/scholar?cites=14180674818440394404&as_sdt=2005&sciodt=0,5&hl=ja', |
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
#include <algorithm> | |
#include <cmath> | |
#include <cstdio> | |
#include <cstring> | |
#include <iostream> | |
#include <numeric> | |
#include <deque> | |
#include <map> | |
#include <queue> |
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 chainer.functions as F | |
import chainer.links as L | |
import numpy as np | |
from chainer import Chain | |
from chainer import cuda, training, Variable | |
from chainer import datasets, iterators, optimizers, initializers | |
from chainer.training import extensions | |
from sklearn.datasets import load_iris | |
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
#ifndef DYNET_HELPER_H | |
#define DYNET_HELPER_H | |
#include <ctime> | |
#include <fstream> | |
#include <iomanip> | |
#include <iostream> | |
#include "dynet/dynet.h" | |
#include "dynet/expr.h" |
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 chainer.functions as F | |
from chainer import Variable, cuda | |
def masked_softmax(x, mask, axis=1): | |
xp = cuda.get_array_module(x, mask) | |
with cuda.get_device_from_array(x, mask): | |
exp_x = F.exp(x) | |
zeros = xp.zeros_like(x.data) | |
sum_exp_x = F.sum(F.where(mask, exp_x, zeros), axis=axis, keepdims=True) |
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 chainer import Chain, report | |
class MultiTaskClassifier(Chain): | |
def __init__(self, task1, task2, loss1, loss2, acc1, acc2, lambda_=1.0): | |
""" | |
:param task1: `Chain` of task 1 | |
:param task2: `Chain` of task 2 | |
:param loss1: loss function of task1 | |
:param loss2: loss function of task2 |
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 tensorflow as tf | |
class Summary(object): | |
def __init__(self, logdir: str): | |
self._placeholders = {} | |
self._observations = {} | |
self._session = tf.Session() | |
self._writer = tf.summary.FileWriter(logdir=logdir) |
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
#include <iostream> | |
using namespace std; | |
int binary_search(int *a, int value, int left, int right) { | |
if (left >= right) return -1; | |
else { | |
int mid = (left + right) / 2; | |
if (a[mid] == value) return mid; | |
else if (a[mid] > value) return binary_search(a, value, left, mid); |