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
// 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 { |
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 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) |
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
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 # 最大反復回数 | |
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 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): | |
"""バッチとして出力するデータのインデックスを乱数で生成する """ |