Skip to content

Instantly share code, notes, and snippets.

View helve2017's full-sized avatar

Helve helve2017

View GitHub Profile
@helve2017
helve2017 / style.less
Created March 22, 2020 05:10
Atomとmarkdownで技術文書を書くためのスタイルシート
// for markdown-preview-plus
body{
counter-reset: figcnt;
counter-reset: tablecnt;
h1, h2, h3, h4, h5 {
font-weight: normal;
border-bottom-style: hidden !important;
}
h1 {
@helve2017
helve2017 / keras_stateful_rnn.py
Last active November 3, 2019 05:01
KerasでステートフルRNNを使ったサンプルコード
# -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
from sklearn.preprocessing import StandardScaler
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, SimpleRNN, GRU, LSTM
#%% data preparation
df = pd.read_csv("osaka_temperature2009_2018.csv",
index_col=0, parse_dates=True)
@helve2017
helve2017 / gradient_descent_armijo.py
Created October 6, 2019 04:15
直線探索(Armijo条件)を使った直線探索のクラス
class GradientDescent:
def __init__(self, fun, der, xi=0.3, tau=0.9, tol=1e-6, ite_max=2000):
self.fun = fun # 目的関数
self.der = der # 関数の勾配
self.xi = xi # Armijo条件の定数
self.tau = tau # 方向微係数の学習率
self.tol = tol # 勾配ベクトルのL2ノルムがこの値より小さくなると計算を停止
self.path = None # 解の点列
self.ite_max = ite_max # 最大反復回数
@helve2017
helve2017 / keras_reccurent_generator.py
Last active June 5, 2020 09:39
Kerasでgeneratorを使った時系列予測のサンプルコードです。
# -*- coding: utf-8 -*-
import numpy as np
from keras.utils import Sequence
from keras.models import Sequential
from keras.layers import Dense, SimpleRNN
class ReccurentTrainingGenerator(Sequence):
""" Reccurent レイヤーを訓練するためのデータgeneratorクラス """
def _resetindices(self):
"""バッチとして出力するデータのインデックスを乱数で生成する """