Tumgik
#riversun
buckybisonstravels · 2 years
Photo
Tumblr media
A beautiful sunset in a beautiful city.
2 notes · View notes
philgennuso · 6 months
Text
Riverside Bouquets (#Nature #Haiku)
Photo by Phil Gennuso Arts by the riversun bakedfresh autumn bouquets
Tumblr media
View On WordPress
10 notes · View notes
riversuntravels · 3 months
Text
Tumblr media
🌄 Dive into the divine realm! 🙏 Set off on a holy journey with #Riversun Tours to the #Chardham sites of Uttarakhand: 🎉️ Yamunotri, 🌊 Gangotri, ⛰️ Kedarnath, and 🙌 Badrinath. Let the #mountains whisper ancient secrets as you #journey to #spiritual enlightenment.
For more info Web: https://riversuntravel.com/ Call: 7017986103
#chardhamyatra #spiritualjourney #divineadventure #riversuntravels #uttarakhandyatra #sacredpilgrimage #himalayanexperience #riversuntravels #yamunotri #gangotri #kedarnath #badrinath
2 notes · View notes
rrechevarria · 1 year
Text
Primal Prism - Prologue
Teaser for a new series I just wrote today, but been planning for a while. Pure fantasy for now, but that may change as I write. Currently planning on it having two lead characters, a Prism Knight, and the runaway Crown Princess. She’s trying to save the kingdom from a corrupt chancellor who may or may not deal with the devil, and he will be tasked with finding her and bringing her to “justice” for stealing a valuable sword–the key to the world’s magic. Still an early WIP.
Crown Princess Sunsea, heir to the Prismatic Key and the lands it unlocked, pulled her cloak tight and watched the soldiers rush into the tower, swords out. Rain prattled against her, wind roaring in her ears.
It was done—the sword had to be stolen. More soldiers emerged from the central tower, swords and spears gleaming with thunderlight as they climbed to towards the southeastern tower. Her home, just a few hours ago. She gripped her sword hilt and crouched, moving away, hiding between the wooden crates spread around the bulwark. Wide enough for a dragon to land—as they once did—with palisades tall enough for a person to hide behind them.
Shadows twisted as the floating white flame moved to her—the remains of a fading fae. And after that day, her only friend.
“It is done,” the fae said. Their voice ringed with echoes of ages past, winds that died down, waters turned to deserts, and forests where nothing but rock grew. “But they know, milady. The Chancellor already blames you for your father’s illness. Word will spread.”
“How long do I have?” The princess fiddled with her golden armlet. Only thing her mother left her, and soon to be sold for survival.
“An hour, give or take, before the full castle is aware of your supposed crimes,” the fae said. “Are you thinking of meeting with the princes? Riversun, if I may be so bold as guessing your next move?”
“He needs to be aware. The others…they’re too young.” Sunsea crossed the bulwark and pressed her back against the raised segment that housed the drawbridge. A guard sat by the upper door, dozing off on the bench. A purple sash adorned his breastplate. Why would a royal guard be stationed there? She stopped, tapping the hilt of her sword. The short and wide blade thrummed inside the pitch-black scabbard, a holy relic crafted out of ancient wood to protect the sword. Twin curved moons adorned the hilt, shimmering with ethereal Light and the ancient magics sealed deep under the castle. She let go of the blade. No need to kill. Yet.
The guard dozed off as she sneaked past him, pushing the door open. It creaked, causing the guard to mumble and scratch his nose. Back to sleep for him. She made it inside, descending the spiraling staircase to the ground floor of the castle, moving into the courtyard.
Her boots scraped over cobblestone as she sneaked closer to the main tower, using the raised benches for cover. Mist coiled around the four holy poinciana trees that slept in the courtyard, each surrounded by the foundations of ancient towers that used to house them. Shimmering leaves danced under the rain, a coat of Light protecting them from bugs and foolish men.
Rumbling. The doors to the tower roared as two soldiers opened them from the inside. Two more walked out, holding a person between them. Gray hair, long, just like hers, and a dark gray face. She gasped as the soldiers dumped the prince on the ground, and he struggled to his feet.
The Chancellor stepped out of the shadowed tower, hands behind his back. Red cloak billowed with the wind, mimicking his red hair. Piercing red eyes and a tanned face marked him a foreigner to the lands of the Primal Prism, a fact that failed to impede his rise to power.
Sunsea took a step forward, but the fae flew in front of her.
“Milady, if you do this, your fate is sealed,” the fae said. She gritted her teeth and glanced beyond the burning ball of light. “You cannot fight them all, milady, not without a Prism in your body.”
The Chancellor stopped, towering over her brother. The doors closed behind him with a loud and final thud. “Your father is ill, soon to pass from this world. With him, the old regime will wither away. None of his children are fit to wear the crown, least of all your sister. She will be blamed for your death. The gallows await her. But you…you have a future at my side. The Senate needs someone to rein them in, and the son of the last king fits that role to perfection.” He crouched, arm over his knee. “The holy trees as our witness, I shall grant you the same blessings as you currently have.”
“I do not believe you,” the prince said.
Swords left their sheaths. Four guards surrounded the Chancellor, their swords pointed at the prince.
“You all wear purple sashes,” the prince said, letting out a bitter laugh. “It is my closest that betray me.” He plucked a dagger from his shirt.
Sunsea darted from the shadows, unsheathing the black blade. Shadows twisted under her, and coiled inside, tainting every muscle with pure power. The Key to the Prism Palace collided with a steel blade with a sharp pang. The hit reverberated across her arms, until the shadows lurking inside of her absorbed the pain. She landed and twisted, pushing the soldier back to block the new stab, coming from a second soldier.
Her brother stood and charged at the other two, while the Chancellor retreated, building a wall of Light to protect himself.
Sunsea ducked a slash and kicked at the soldier, toppling him. She used the fallen soldier to jump at the second, swinging her sword from above, smashing against the silver blade. Thunder echoed. She kicked at the soldier’s face, still in the air, and took him down.
The wisp of flame floated to her. “Milady, sheathe the blade!”
Shadows crawled around her, digging at her skin. She smashed the sword into the sheath and gasped as the threatening powers vanished.
Her brother stood watching the two bodies, turning to the Chancellor. “Run, Sunsea. You are father’s only hope. Bring a cure to drive away the evil plaguing his heart. Only then can the Chancellor be stopped.”
“Or now, if we fight together,” Sunsea said.
The air shimmered in front of the Chancellor. A diamond floated there, made of Prism Light. Shades stirred inside, a head, a tail, wings. Cracks appeared in the diamond.
A summoning.
How? She gritted her teeth and dashed away. Whatever creature was inside would demolish her. The prince had two Prisms inserted in his body, making him able to manipulate Light to an extent she could only dream of. The sword could consume her if she was reckless.
Rage boiling in her heart, Crown Princess Sunsea rushed towards the southwestern tower, to the hole by the stables that provided an escape for the two of them.
One last time. She glanced back. A figure emerged from the diamond, a crystalline dragon that breathed white translucent flames, searing her brother’s Light barriers.
Never again. She would not be late. Not anymore.
7 notes · View notes
namenerdery · 8 months
Text
Babies with interesting names born in Vermont between 2008-2019 [R, S & T]
Raghallaigh Ren Lou Railynn Noel Ransom Jacksie Rarity Ty Rayder Jameson Raynebeau Skyee Raynon Timber Razael Stephen Razalin Roxxanne Reabeka Mary Lee Rebel Dawn Renegade Reveille Win Rexley Augustus Rheal Philip Rheigmond Timothy-Scott Rider James Rieliegh Mae Jamison Riot Paul Ripley Ruex Ripple Praetsch Ritter Jude Riversun Stanley Rocky Coast Rowdy Curtis Rumi Courage James Rydder Thomas Ryot Dawson
Saebryn Jane Saeghan Marie Sailor Seneca Scout Saquoiah Wynter Saveren James Scenic Lynn Seven Katrina Shadow Bradley Sherlock Arthur Snoh Leigh Solaar Rayne Solace Gray Solden Mae Soule Ann Sparrow Mark Starlit Lee Ann Starr Mourning Stihl Dennison Storm Lightning Strummer Raven Swan Mae Sycada Cyprien Sylvanas Juliet Syvahna Rae Syzygy Peregrine
Teeken Hartly Azel Temprence Anyssa Theory Evelyn Thinley Kayla Thumperlee Robert Russell Tigre Leone Traeh Remingten Trigger Allen Trillium Shadow Truly-Meriadoc Moonlight Tupper Moss Tuscan Sage Tyke Nathaniel Tykillian Christopher
0 notes
Photo
Tumblr media
Source: riversun, via IslamicArtDB
143 notes · View notes
silverfrostart000 · 3 years
Text
Tumblr media
Riversun (OC)
1 note · View note
sidelinemedia · 5 years
Photo
Tumblr media
Sunset on the Piankatank River! @canonusa @canonglobal @middlesexcova #canon #canonphotography #canoncamera #canon_photo #riversun #sunset #potd #pictureoftheday #notsports #nottheusual #relaxing #everythingisgoingtobealright #godspallette #photosofdeltaville (at Deltaville, Virginia) https://www.instagram.com/p/Bpk1TZtHLVz/?utm_source=ig_tumblr_share&igshid=1o88bgdoj0rim
0 notes
sunzambian · 3 years
Text
Congolese woman drowns in Kafue River
Congolese woman drowns in Kafue River
Congolese woman drowns in Kafue RiverSun REPORTER writesA 27-year-old woman from the Democratic Republic of Congo (DRC) on Saturday drowned in the Kafue River as she was trying to position herself to take a selfie.The woman arrived in the country from the DRC in July, this year to visit her brother-in-law in Lusaka.On Saturday, the woman in the company of her friend travelled to Kafue District to…
Tumblr media
View On WordPress
0 notes
masaa-ma · 5 years
Text
機械学習にとって大切なことは全部MSE(平均二乗誤差)が教えてくれた
from https://qiita.com/riversun/items/b691cc0fa8a8a8f42013?utm_campaign=popular_items&utm_medium=feed&utm_source=popular_items
概要
機械学習の回帰問題において評価関数としてよく出てくるMSE(mean squared error,平均二乗誤差)とは一体何なのか。
山登りのように、ふもとから一歩ずつふみしめながら理解をすすめていく記録となります。
(必要な数式の導出過程も省略せず記録しました)
とうことで、さっそく山登り開始します
1合目:母集団・母平均
登り始める前に、準備運動。統計用語をおさらい
「日本人成人男性の平均身長調査」 を題材に、考えてみる。
選挙年齢が引き下げられたので、成人=18歳以上 とすると該当するは約1億人、そのうち男性が約半数なので、日本人成人男性は5000万人程度と考える。
母集団(ぼしゅうだん、population)
母集団とは、調査対象となる数値、属性等の源泉となる集合全体
平均身長調査で考えると、母集団とは対象者全員ということになる。
つまり母集団は5000万人(の日本人成人男性たち)
母平均(ぼへいきん,population mean)
母平均とは、母集団の平均のこと。平均は英語で mean その頭文字mに対応するギリシア文字$μ$(ミュー)を使うことが多いので、本稿でも$μ$をつかう。
さて、平均身長調査で考えると、母平均は以下のように計算できる。
母平均 μ=\frac{対象者全員ぶんの身長の総和}{5000万}
ちなみに、18歳以上の日本人成人男性の平均身長 $ μ=170.9cm $ だそう
2合目:大数の法則
大数の法則(たいすうのほうそく,Law of Large Numbers)
大数の法則とは、以下のような法則
「ある母集団から標本を抽出するとき、抽出する数が大きくなればなるほど、標本の平均は$μ$に近づく」 ($μ$は母集団の平均である母平均)
平均身長調査をしたら以下のようになったとする
母集団から10人の身長を無作為に抽出したら、その平均は166.5cmだった
母集団から50人の身長を無作為に抽出したら、その平均は169.2cmだった
母集団から500人の身長を無作為に抽出したら、その平均は170.5cmだった
多くの標本を抽出すると、その平均が 母平均 $ μ=170.9cm $ に近づいていくことがわかる。
このように母集団から抽出した標本の平均のことを標本平均という
3合目:確率変数
確率変数(かくりつへんすう、 random variable)
確率変数とは「どのような値をとるかが、ある確率によって決まる変数」
確率変数には$ X $がよく使われる。
平均身長調査で考える。
任意に抽出した人の身長を確率変数$ X $と考えると、 数学的には、「確率変数$ X $は 対象となる人→その身長 という関数」を意味する。
身長180cm以上190cm以下の確率、150cm未満の確率など、 確率変数は確率分布に対応し、妥当にあり得る範囲の確率を計算できる。 (wikipediaより)
平均身長調査で母集団から標本を抽出したとき、抽出した身長データ $ \mathbf{x}_1,\mathbf{x}_2,...\mathbf{x}_n $ (cm)は確率変数$ \mathbf{X}_1,\mathbf{X}_2,...\mathbf{X}_n $の実現値と考えることができる。$n$は標本の大きさという。
実現値(観測値)・・・実際の試行の結果として観察された値
4合目:期待値と平均
期待値(きたいち、expected value)
期待値とは「確率変数のすべての値に確率の重みをつけた加重平均」のこと
確率変数$X$の期待値は、$E(X)$で表すことが多い。
平均身長調査で考える。
任意に抽出した人の身長を確率変数$ X $としたとき、 母集団から標本を抽出したとき、抽出した身長データ $ \mathbf{x}_1,\mathbf{x}_2,...\mathbf{x}_n $ (cm)のそれぞれの発生確率(その身長の人がどのくらいの割合いるのか)を$\mathbf{p}_1,\mathbf{p}_2,...\mathbf{p}_n $とすると、その期待値$E(X)$は以下のように計算1する。
E(X) = \sum_{i=1}^{n}\mathbf{x}_i\mathbf{p}_i
期待値の性質①「和の期待値は期待値の和」
和の期待値は期待値の和となる性質がある(期待値の線形性)
期待値の性質②「定数の期待値は定数」
期待値の性質③「(定数+確率変数)の��待値は、定数+確率変数の期待値」
期待値の性質④「(定数x確率変数)の期待値は、定数x確率変数の期待値」
期待値と平均の違い
期待値と平均の違いは平均の定義を見て考える必要がある。
確率変数の平均
確率変数$X$の平均は確率変数すべての値に確率の重みを付けた加重平均であり、これは期待値のことを示す
E(X) = \sum_{i=1}^{n}\mathbf{x}_i\mathbf{p}_i
母集団の平均(期待値)を$μ$とすれば、
μ = E(X) = \sum_{i=1}^{n}\mathbf{x}_i\mathbf{p}_i
となる
標本平均
以下の平均身長調査の例を再度考える
母集団から10人の身長を無作為に抽出したら、その平均は166.5cmだった
母集団から10件の標本を抽出したら以下のようなデータが取得できたとする
x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 平均
160 166 162 163 172 169 166 168 172 167 166.5
この標本の平均は、母集団から標本を抽出したとき、抽出した身長データ $ \mathbf{x}_1,\mathbf{x}_2,...\mathbf{x}_n $ (cm)としたとき、抽出した身長データの総和を、抽出した個数$n$で割ったものとなる
\begin{align} \frac{x1+x2+x3+x4+x5+x6+x7+x8+x9+x10}{n}&=\\ \\ \frac{160+166+162+163+172+169+166+168+172+167}{10} &= 166.5 \end{align}
つまり平均$E[X]$を式で表すと以下のようになる
E(X) = \frac{\sum_{i=1}^{n}\mathbf{x}_i}{n}
平均を表す場合はよく変数の頭にバーをつけて$ \bar{x}$のようにするので以下のようにした
標本平均 \bar{x} = E(X) = \frac{\sum_{i=1}^{n}\mathbf{x}_i}{n}
ここで、標本の大きさ$n$ をどんどん大きくしていって平均身長調査の母数5000万人に近づけていったらどうなるか。
大数の法則を思い出すと、
「ある母集団から標本を抽出するとき、抽出する数が大きくなればなるほど、標本の平均は$μ$に近づく」 ($μ$は母集団の平均である母平均)
であるので、 標本の大きさ$n$を大きくしていくと、標本平均 $\bar{x}$は母平均μに限りなく近づく
つまり、5000万人近いの標本(身長データ)を集めることができれば、その標本平均は母平均と一致する。母平均とは母集団の平均=期待値なので、この場合、標本平均=期待値となる。
まとめると、
確率変数$X$の平均は確率変数すべての値に確率の重みを付けた加重平均であり、これを期待値とも呼ぶ
μ = E(X) = \sum_{i=1}^{n}\mathbf{x}_i\mathbf{p}_i
標本平均$\bar{x}$は標本の大きさ$n$が増えるほど、大数の法則により母集団の平均$μ$(期待値)に限りなく近づく
\begin{align} \bar{x} &= E(X) = \frac{\sum_{i=1}^{n}\mathbf{x}_i}{n}\\ &n → ∞のとき μ = \bar{x}
\end{align}
確率論的視点と統計学的視点
ここまでで、だんだん気づいてきたとおもうが、いままでのトピックは一定の確率をもって変数が決まる確率論的見方と、母集団から標本を抽出して母集団の推測しようとする統計学的見方と両方の視点であえてごちゃっと見てきた。
どちらかというと、目に見えづらい確率論的見方よりも、標本を集めて統計的処理をしていく統計学的視点のほうがピンと来る気もするが機械学習の理論を学ぶ上ではどちらの見方も重要だと考える。
5合目:分散
分散(ぶんさん、variance)
分散は英語よみそのままでバリアンスともいう。
分散とは「確率変数値が全体として「平均」からどれだけ散らばっているかを表す特性値」のこと。
分散は平均からの散らばり具合を示し、0に近いほど散らばりが少ない(まとまっている)、大きいほど散らばっている(ばらばらになっている)
分散はVarianceなので、分散を関数的に表すとき$ V[X] $や $VAR[X]$、$Var[X]$などが好んで使われる。
さて、確率論的見方と統計学見方の両方の定義をみていく。
確率変数の分散
まず、確率論的見方から。
確率変数$X$の期待値を$E[X]$とすると、分散$V[X]$は以下のようになる
つまり、確率変数$X$ からその期待値$E(X)$を引いた値の二乗の期待値となる。
上の式は、あとでMSE(平均二乗誤差)を計算するときに展開するので覚えておくとよい。
標本の分散
次は統計学的見方で分散を見る
ある母集団から抽出した標本の分散を標本分散という
$\mathbf{x}_1,\mathbf{x}_2,...\mathbf{x}_n $ からなる標本があり、その平均を$\bar{x}$としたときこの標本の分散は以下の数式で計算される
s^2=\frac{1}{n}\sum_{i=1}^{n}(\mathbf{x}_i-\bar{\mathbf{x}})^2 \\
$s$は標準偏差を示す。
この式のとおり、標準偏差を二乗したものを分散というので、$標準偏差=\sqrt{分散}$となる
\begin{align} 標準偏差 &= \sqrt{分散}\\ s &= \sqrt{\frac{1}{n}\sum_{i=1}^{n}(\mathbf{x}_i-\bar{\mathbf{x}})^2} \end{align}
母集団の分散
母集団の分散(母分散)も、計算式は標本の分散と同じだが、分散の記号として$\sigma^2$がよく使われる。 $\mu$は母集団の平均(母平均)、$\sigma$は母集団の標準偏差。
\sigma^2=\frac{1}{n}\sum_{i=1}^{n}(\mathbf{x}_i-\bar{\mu})^2 \\
6合目:分散の式の展開
ひきつづき、分散をみていく。 分散というのは、統計学では最も重要な概念ともいわれているし、今回の目的でもあるMSE(平均二乗誤差)を考える上でも非常に重要なので丁寧にみていく。
分散の式を展開する
分散の式は以下のように展開可能である
\begin{align} V[X]=\sigma^2&=E[(X-E(X))^2]\\ &=E[X^2]-E[X]^2 \end{align}
計算過程がよく飛ばされるので、今回は丁寧にみていく
\begin{align} V[X]=\sigma^2&=E[(X-E(X))^2] \tag{1}\\ &=E[X^2-2XE[X]+E[X]^2] \tag{2}\\ \end{align}
さて、ここで(2)の式に注目すると、一番外側の$E[ ]$にとって、その内側にいる$E[X]$と$E[X]^2$は定数扱いとなる。
この状態で、期待値の性質①をつかって式(2)を分解すると式(3)のようになり、
期待値の性質①「和の期待値は期待値の和」
\begin{align} V[X]=\sigma^2&=E[(X-E(X))^2] \tag{1}\\ &=E[X^2-2XE[X]+E[X]^2] \tag{2}\\ &=E[X^2]-E[2XE[X]]+E[E[X]^2] \tag{3}\\ \end{align}
さらに、外側の$E[ ]$の内側にいる$E[X]$と$E[X]^2$は定数扱いとなるので、式(4)のようにできる
\begin{align} V[X]=\sigma^2&=E[(X-E(X))^2] \tag{1}\\ &=E[X^2-2XE[X]+E[X]^2] \tag{2}\\ &=E[X^2]-E[2XE[X]]+E[E[X]^2] \tag{3}\\ &=E[X^2]-2E[X]E[X]+E[X]^2 \tag{4}\\ \end{align}
式(3)から式(4)の展開をもう少し詳しくみると以下のようになる。
$E[2XE[X]]$の2は定数、また$E[X]$も外側の$E[ ]$にとっては定数なの期待値の性質④「(定数x確率変数)の期待値は、定数x確率変数の期待値」より、外だしして$2E[X]E[X]$となる。
次の$E[E[X]^2]$は、内側の$E[X]^2$は外側の$E[ ]$にとって定数となるので期待値の性質②「定数の期待値は定数」より$E[定数]=定数$と考えることができるので$E[E[X]^2]=E[X]^2$となる。
さて、残り展開を式(5)と式(6)のようにして以下のようになった
\begin{align} V[X]=\sigma^2&=E[(X-E(X))^2] \tag{1}\\ &=E[X^2-2XE[X]+E[X]^2] \tag{2}\\ &=E[X^2]-E[2XE[X]]+E[E[X]^2] \tag{3}\\ &=E[X^2]-2E[X]E[X]+E[X]^2 \tag{4}\\ &=E[X^2]-2E[X]^2+E[X]^2 \tag{5}\\ &=E[X^2]-E[X]^2 \tag{6}\\ \end{align}
これにより、さきほど求めたかった以下の関係を導出できた
\begin{align} V[X]=\sigma^2&=E[(X-E(X))^2]\\ &=E[X^2]-E[X]^2 \end{align}
分散の計算過程を今回は確率変数$X$の例で計算したが、これは母分散や標本の分散の計算式でも同じ事がいえる。
\begin{align} s^2&=\frac{1}{n}\sum_{i=1}^{n}(\mathbf{x}_i-\bar{\mathbf{x}})^2 \\ &=\frac{1}{n}\sum_{i=1}^{n}\mathbf{x}_i^2-\bar{\mathbf{x}}^2 \\ \end{align}
7合目:MSE(平均二乗誤差,mean squared error)の定義
ようやく7合目まできた いよいよMSEの定義をひもといていく。
学習モデルと真のモデルとMSE
式の意味や定義を理解しやすくするために、以下のような状況を設定する
ある母集団から無作為に$標本_1,標本_2,,,標本_n$を抽出する
この標本に$x$、$y$の変数があるとき、それをプロットすると以下のようになったとする
この標本を入力として機械学習をさせて得られた学習モデルを$\hat{f}(x)$とする。
$\hat{f}(x)$は以下の赤線のようになる
以下のようになる($\hat{y}$は学習モデルの予測値)
このように、この学習モデル$\hat{f}(x)$をつかえば$x$から$y$を予測することができる
ちなみに、$\hat{y}$や$\hat{f}(x)$の上に$\hat{}$がついているが、一般に予測や推定を示す関数や値にはハット($\hat{}$)をつけて表現することが多いので覚えておく
学習によって得られた学習モデル$\hat{f}(x)$は$標本_1,標本_2,,,標本_n$の近似をしている関数 と考えるとわかりやすい
ところで、学習モデル$\hat{f}(x)$は観測済みの標本から作られているのに対して、真のモデル$f(x)$は直接観測することはできない。
真のモデルを$f(x)$とすると、その値$y$(真の値)との関係は以下のようになる
$\epsilon$(イプシロン)は真のモデル自身がもつノイズ。これは真のモデルにどうしても内在するもので、コントロール不可能なもの。
$\epsilon$は平均が0、分散が$\sigma^2$の分布を持つ
真のモデル$f(x)$のイメージは以下の点線のような感じになる (真のモデルは外部から観測できないので、ほんとうは描けない)
学習モデルが予測した$y=\hat{f}(x)$と真のモデル$f(x)$とノイズ$\epsilon$(平均:$0$、分散:$\sigma^2$)から来る真の値$\hat{y}=f(x)+\epsilon$の差が小さいほど学習モデルは本当の値をよく近似できているといえるので、この差を小さくするのが学習の目的となる。
\begin{align} 真の値・・・y&=f(x)+\epsilon\\ 予測値・・・\hat{y}&=\hat{f}(x)\\ \end{align}
学習モデル$\hat{f}(x)$のMSE(平均二乗誤差)の式は以下のようになる
\begin{align} MSE[\hat{f}(x)]&=E[(y-\hat{f}(x))^2]\\ &=E[((f(x)+\epsilon)-\hat{f}(x))^2]\\ \\ &\epsilon・・・平均:0,分散:\sigma^2 \end{align}
8合目:汎化誤差と訓練誤差(経験誤差)
訓練誤差(Training error)
ところで、いまみてきた学習は、ある母集団から無作為に抽出した$標本_1,標本_2,,,標本_n$を抽出するをつかって行った。
そこでできた学習モデルは当然ながら標本を参考にしてできたものとなる
学習モデルが予測した値を赤丸●でプロットしたのが以下の図となる
実際の値は標本の黒丸●で、予測値が赤丸●となるが、●と赤丸●の差が訓練誤差となる。
訓練誤差とは、学習につかった値と、学習モデルの予測した値の誤差のことを指す。ここでいえば、標本を学習につかっているので、観測済みの標本と予測値の誤差となる。
訓練誤差は、経験誤差、学習誤差、経験損失ともよぶ。
汎化誤差(Test Error)
それに対して、 汎化誤差は真のモデルと学習モデルの誤差を指す。まだ観測されていない値を含む真のモデルと学習モデルの誤差。
前節で以下のように書いたが、より詳しくいえば
学習モデル$\hat{f}(x)$と真のモデル$f(x)$の差が小さいほど学習モデルは本当の値をよく近似できているといえるので、この差を小さくするのが学習の目的となる。
「学習の目的は学習モデルと真のモデルの差つまり汎化誤差が小さくなるようにする」ことが重要といえる。
ということで、機械学習の目標は汎化(generalization)性能の獲得、つまり汎化誤差の最小化といえる
汎化誤差は、テスト誤差、期待損失ともいう。
9合目:バイアスとバリアンスのトレードオフとMSE
MSEの計算式を展開する
7合目を思い出す
学習モデルが予測した$y=\hat{f}(x)$と真のモデル$f(x)$とノイズ$\epsilon$(平均:$0$、分散:$\sigma^2$)から来る真の値$\hat{y}=f(x)+\epsilon$の差が小さいほど学習モデルは本当の値をよく近似できているといえるので、この差を小さくするのが学習の目的となる。
\begin{align} 真の値・・・y&=f(x)+\epsilon\\ 予測値・・・\hat{y}&=\hat{f}(x)\\ \end{align}
学習モデル$\hat{f}(x)$のMSE(平均二乗誤差)の式は以下のようになる
\begin{align} MSE[\hat{f}(x)]&=E[(y-\hat{f}(x))^2]\\ &=E[((f(x)+\epsilon)-\hat{f}(x))^2]\\ \\ &\epsilon・・・平均:0,分散:\sigma^2 \end{align}
バイアスとバリアンスの話をするために、重要となるのが、以下の式(1)となる。
\begin{align}
MSE[\hat{f}(x)]&=E[(y-\hat{f}(x))^2]\\ &=E[((f(x)+\epsilon)-\hat{f(x)})^2] \\ &=E[\hat{f}(x)^2]-2f(x)E[\hat{f}(x)]+f(x)^2+\sigma^2 \tag{1}\\ \end{align}
ここでは、MSEの式を展開して式(1)$MSE[\hat{f}(x)]=E[\hat{f}(x)^2]-2f(x)E[\hat{f}(x)]+f(x)^2+\sigma^2$を導出していく。
$MSE[\hat{f}(x)]$
\begin{align} &=E[((f(x)+\epsilon)-\hat{f(x)})^2] \\ &=E[(f(x)+\epsilon)^2-2(f(x)+\epsilon)\hat{f}(x)+\hat{f}(x)^2] \tag{2}\\ &=E[f(x)^2+2\epsilon f(x)+\epsilon^2-2f(x)\hat{f}(x)-2\epsilon\hat{f}(x)+\hat{f}(x)^2] \tag{3}\\ &=E[f(x)^2]+E[2\epsilon f(x)]+E[\epsilon^2]-E[2f(x)\hat{f}(x)]-E[2\epsilon \hat{f}(x)]+E[\hat{f}(x)^2] \tag{4}\\ &=E[f(x)^2]+2E[\epsilon]E[f(x)]+E[\epsilon^2]-2E[f(x)]E[\hat{f}(x)]-2E[\epsilon]E[\hat{f}(x)]+E[\hat{f}(x)^2] \tag{5}\\ \end{align}
式(5)について、各項にでてくる$\epsilon$について考察する。
まず、$E[\epsilon]$について。$\epsilon$は平均が0のノイズ成分なので、$E[\epsilon]=0$となる。
また、6合目でみた以下の分散$V[X]$の式より、
\begin{align} V[X]&=E[(X-E(X))^2]\\ &=E[X^2]-E[X]^2 \end{align}
であるので、これを変形すると
ここに$\epsilon$を代入すると
E[\epsilon^2]=V[\epsilon]+E[\epsilon]^2 \tag{7}\\
となる。$\epsilon$の定義より分散$V[\epsilon]=\sigma^2$、$E[\epsilon]=0$であるので式(7)は
\begin{align} E[\epsilon^2]&=V[\epsilon]+E[\epsilon]^2 \\ &= \sigma^2+0^2 \\ &=\sigma^2 \end{align}
となり、
E[\epsilon^2]=\sigma^2\tag{8}\\
式(6)(8)より、$E[\epsilon]=0$、$E[\epsilon^2]=\sigma^2$であるので、式(5)は
となるので
$MSE[\hat{f}(x)]$
\begin{align} &=E[f(x)^2]+2E[\epsilon]E[f(x)]+E[\epsilon^2]-2E[f(x)]E[\hat{f}(x)]-2E[\epsilon]E[\hat{f}(x)]+E[\hat{f}(x)^2]\\ &=E[f(x)^2]+\sigma^2-2E[f(x)]E[\hat{f}(x)]+E[\hat{f}(x)^2]\tag{9}\\ \end{align}
これまでと同様、$\hat{f}(x)$の関数において$E[f(x)]$の$f(x)$は定数であるので
\begin{align}
MSE[\hat{f}(x)]&=f(x)^2+\sigma^2-2f(x)E[\hat{f}(x)]+E[\hat{f}(x)^2]\tag{10}\\ \end{align}
式(10)の各項の順番を入れ替え
\begin{align}
MSE[\hat{f}(x)] &=E[\hat{f}(x)^2]-2f(x)E[\hat{f}(x)]+f(x)^2+\sigma^2\tag{11}\\ \end{align}
以下のように式(1)を導出することができた
\begin{align}
MSE[\hat{f}(x)] &=E[((f(x)+\epsilon)-\hat{f(x)})^2] \\ &=E[\hat{f}(x)^2]-2f(x)E[\hat{f}(x)]+f(x)^2+\sigma^2  \tag{1}\\ \end{align}
この結果を覚えておきつつ、バイアスをみていく
バイアス(bias)とは
バイアスとは、偏りのことを意味する。
学習によって得られた学習モデルを$\hat{f}(x)$、直接観測できない真のモデルを$f(x)$とすると $\hat{f}(x)$のバイアス$Bias(\hat{f}(x))$は以下のようになる
Bias[\hat{f}(x)]=E[\hat{f}(x)-f(x)]
バイアスは学習モデルによる予測値と真の値の期待値の差なので、バイアスが高い(high bias)とモデルの精度がわるい
訓練データをつかって、機械学習するとき、バイアスが高いと、いくらたくさん訓練データを入力してもモデルの精度が悪いまま。テストデータ(学習済みのモデルの性能を評価するためのデータ)をつかっても、モデルの精度が悪い。
なので、なるべくバイアスを低くしたい。
バリアンス(variance,分散)とは
バリアンスは分散のこと。分散は5合目で見てきたとおりで、
分散とは「確率変数値が全体として「平均」からどれだけ散らばっているかを表す特性値」 となる。
\begin{align} V[X]=\sigma^2&=E[(X-E(X))^2]\\ &=E[X^2]-E[X]^2 \end{align}
学習によって得られた学習モデルを$\hat{f}(x)$としたとき、$\hat{f}(x)$の分散は
\begin{align} V[\hat{f}(x)]&=E[(\hat{f}(x)-E(\hat{f}(x)))^2]\\ &=E[\hat{f}(x)^2]-E[\hat{f}(x)]^2 \end{align}
となる。
バリアンスとは、平均からの散らばり具合だが、ここでいう平均とは、学習モデルが予測した値の平均。個々の予測値と、予測値の平均が離れている状態はバリアンスが高い(high variance)という。
モデルを複雑にしていくと、よく訓練データにフィットするようになる(バイアスが低くなる)が 訓練データにフィットしすぎ(overfit)て、テストデータにはフィットしなくなる。 こういう状況はバリアンスが高い(high variance)状態となる。
このようにバリアンスはモデルが複雑になるほど高くなりモデルが不安定になる
MSEはバイアス(bias)とバリアンス(variance)の成分でできていることを確認する
バイアスとバリアンスの特徴を軽く把握したところで、MSEとバイアスとバリアンスの関係をみてみる。
結論からいうと、
MSE[(\hat{f}(x)]=V[(\hat{f}(x)]+Bias[(\hat{f}(x)]^2+\sigma^2
となる。
これを式で確かめてみる
バリアンス=分散$V[\hat{f}(x)]$は以下の通り、
\begin{align} V[\hat{f}(x)] &=E[\hat{f}(x)^2]-E[\hat{f}(x)]^2 \end{align}
バイアス$Bias[\hat{f}(x)]$の二乗$Bias[\hat{f}(x)]^2$を計算すると以下の通り
\begin{align} Bias[\hat{f}(x)]&=E[\hat{f}(x)-f(x)]\\ \\ Bias[\hat{f}(x)]^2&=E[\hat{f}(x)-f(x)]^2\\ &=E[\hat{f}(x)]^2-2f(x)E[\hat{f}(x)]+f(x)^2 \end{align}
であるので、
\begin{align} V[\hat{f}(x)]+Bias[\hat{f}(x)]^2&=(E[\hat{f}(x)^2]-E[\hat{f}(x)]^2) + (E[\hat{f}(x)]^2-2f(x)E[\hat{f}(x)]+f(x)^2)\\ &=E[\hat{f}(x)^2]-2f(x)E[\hat{f}(x)]+f(x)^2\\ \\ MSE[\hat{f}(x)] &=E[\hat{f}(x)^2]-2f(x)E[\hat{f}(x)]+f(x)^2+\sigma^2 \\ \\ V[\hat{f}(x)]+Bias[\hat{f}(x)]^2+\sigma^2 &=E[\hat{f}(x)^2]-2f(x)E[\hat{f}(x)]+f(x)^2+\sigma^2 \end{align}
これにより、以下のように、MSE(平均二乗誤差)は$V$と$Bias^2$と真の値に含まれる誤差の分散$\sigma^2$によって構成される値であることが確認できた。
\begin{align} MSE[\hat{f}(x)] &=V[\hat{f}(x)]+Bias[\hat{f}(x)]^2+\sigma^2\\ &=E[\hat{f}(x)^2]-2f(x)E[\hat{f}(x)]+f(x)^2+\sigma^2 \\ \end{align}
バイアス(bias)とバリアンス(variance)のトレードオフ
バイアスが高い(high bias)とき
以下はのように標本に対して、直線で近似した学習モデルが――とする
バイアス$Bias[\hat{f}(x)]$は以下のように、学習モデル$\hat{f}(x)$と真のモデル$f(x)$の差から計算される
\begin{align} Bias[\hat{f}(x)]&=E[\hat{f}(x)-f(x)]\\ \end{align}
学習モデル$\hat{f}(x)$と真のモデル$f(x)$の$\hat{f}(x)-f(x)$を図示すると以下のような感じ
上図のように、バイアスが高いと学習モデルと真のモデルの差$\hat{f}(x)-f(x)$が大きい=精度の悪いモデルしかできない。こういう状態を underfit という。
バイアスを低く(low bias)する
では、反対に学習モデルと真のモデルの差$\hat{f}(x)-f(x)$を徹底的に小さくするように学習させたとする。
学習モデルでは直線ではなく、もっと複雑な関数で近似してみると以下のようになったとする。
訓練データ(標本)にみごとに一致している学習モデルが出来た。
この状態はバイアスは非常に低いが、今度はバリアンス(variance)が高くなっている状態。
トレードオフ関係
トレードオフ関係とは、こちらを良くしようとすると、あちらが悪くなる という関係。
複雑なモデルにするとバリアンスが高くなるが、バリアンスが高いと過学習といって訓練データに過剰にフィット(overfit)してしまっている
過学習がおきていると、訓練データに対してはよくフィットするが、 訓練データ外のデータ、たとえばテストデータがくると下図のように予測がハズれて、精度が落ちてしまうという現象がおこりやすい。
つまり、 バイアスを低くしようとすると、バリアンスが高く(overfitするリスク)なる というトレードオフの関係が存在するので、両者を良い感じに調整するのが学習モデルをつくる上でのポイントとなる。
上でみたように、
\begin{align} MSE[\hat{f}(x)] &=V[\hat{f}(x)]+Bias[\hat{f}(x)]^2+\sigma^2\\ \end{align}
の関係があるので、 MSE(平均二乗誤差)を小さくする(バイアスもバリアンスも小さくなればMSEも小さくなる)という方針は、良い学習モデルを作るということになる。
10合目:母数の推定
MSE登山も、だいぶ高いところまで上ってきて、ようやく山頂が見えてきたような
MSEの計算(予測値)
学習モデル(もう学習済みのモデル)で予測(回帰)を行ったとき、MSEの計算をする方法を再確認しておく。
つまり訓練誤差ではなく汎化誤差の計算をする場合、
学習モデルを$\hat{y}=\hat{f}(x)$、
テストデータ(学習に使ってないデータ)が$N$個
テストデータの値を順番に $y_0,y_1,y_2,,,y_{N-1}$ とする
学習モデルによって予測された予測値を $\hat{y}_0,\hat{y}_1,\hat{y}_2,,,\hat{y}_{N-1}$ 
とするとき、MSEは以下のように計算できる。
MSE[\hat{\mathbf{y}}] = \sum_{i=0}^{N-1} (\mathbf{y}_i - \hat{\mathbf{y}}_i)^2
MSEの計算(母数推定)
これまでは、標本にある具体的な変数に関して変数$X$と変数$Y$の関係を機械学習によってモデル化する視点でMSEをみてきた。
これと同様に、母数の推定においてもこれまでみてきたMSEの計算式と同様の考え方ができるので少しふれておく。
ちなみに、機械学習のプログラミングをする上では、9合目までの知識でそんなに困らない気がするので、ここはさらっと。
MSEの解説を調べたりすると、けっこうな確率で母数の推定の話($\theta$や$\hat{\theta}$がドヤ顔で使われた数式)がでてくるので、そういうときに困惑しない程度に。
母数(parameter)とは
母数は英語だとパラメータ。
母数とは、確率変数の確率分布を特徴付ける数である。たとえば、ポアソン分布では平均 λ, 正規分布では平均 μ および分散 σ2 がこれにあたる
wikipediaより
推定量(Estimator)とは
推定量(すいていりょう)とは、現実に測定された標本データをもとに、確率分布の母数(パラメータ、現実には測定できない)として推定した数量(英語:Estimate)、もしくはそれをデータの関数として表す推定関数(すいていかんすう:Estimator)のことをいう。
wikipediaより
母数(parameter)の推定
母数には良く$\theta$がつかわれ、推定量は良く$\hat{\theta}$が使われる。どちらも単なる記号なので難しいことはない。
推定量のMSE(平均二乗誤差)は以下の式であらわされる
MSE[\hat{\theta}]=E[(\hat{\theta}-\theta)^2]
また、
MSE[\hat{\theta}]=V[\hat{\theta}]+(Bias[\hat{\theta}])^2
の関係が成り立つ。
いままでみてきたものと似ているし、導出の過程もほぼ同じ、なので、このくらいで。
PredictorとEstimator
学習モデルによって、数値や分類を予測(回帰)するときの予測器をPredictor、 母数の推定量( or 推定するための関数)をEstimator という。
英語文献などでは、明確に分けて書いてあるのでおぼえておく。
ちなみに、このあたりの定義については論争もある模様。参考程度に。
山頂へ(まとめ)
MSEについて山登りをして、ようやく山頂についたかな、という感じです。
基本的な確率・統計のキーワードや大数の法則からからはじめて、確率、期待値・平均とすすめ5合目までは統計学でも特に重要な概念といわれる分散を理解するためのステップでした。
6合目から先はMSE(平均二乗誤差)の性質を理解するためのステップでバイアスとバリアンスという成分でできていることを理解できました。
10合目の入り口ではMSEの計算法や母数の推定についての考え方を簡単に整理しました。
MSEを調べていくと、機械学習に必要な確率・統計の知識が自然と学習できてなかなかお得感がありました。
MSEの山頂に登った気でいますが、 その先にまだまだ、奥深い世界が広がっているので歩みをとめず、先に進んでいきたいと思います。
最後までお読みいただき、ありがとうございました
参考にした資料・文献等
(順不同)
0 notes
awsexchage · 5 years
Photo
Tumblr media
JavaでLambda関数を書いてSAMでデプロイしてみた https://ift.tt/33bMEqb
はじめに
 これまで、AWS Lambdaを主にPython、時々、Node.jsで作ってきましたが、気分転換にJavaでの開発方法を調べたのでまとめます。
 今回は、Javaで書いたLambda関数のソースコードをGradleでビルドしてAWS SAMでデプロイしてみました。  Eclipseでの開発用に AWS Toolkit for Eclipse も提供されていますが、普段はVimで開発してCLIでデプロイしているので、そちらに合わせます。
検証環境
OS: macOS High Sierra 10.13.6
aws-cli: 1.15.38
aws-sam: 0.11.0
Java 1.8.0_221
JDK: OpenJDK 1.8.0_212 (Amazon Corretto 8.212)
Gradle 5.5.1
JavaでLambdaを開発する上でのポイント
ランタイムはJava 8のみ
 下の公式ドキュメントにあるように、提供されているJavaのランタイムはJava 8 (JDK 8)のみです。  それ以外のバージョンを使用する場合は、サポートされるまで待つかカスタムランタイムを使う必要があります。
Java による Lambda 関数のビルド – AWS Lambda
zipファイルかjarファイルにしてでデプロイ
 Javaで書かれたアプリケーションを、zipファイルまたはスタンドアロンjarにパッケージしてデプロイします。
 公式ドキュメントではMavenを使ってスタンドアロンjarに、Gradleを使ってzipファイルにしてデプロイする方法が紹介されてます。  今回は、Gradleでzipファイルにパッケージングしてデプロイする方法で試しました。
Java の AWS Lambda デプロイパッケージ – AWS Lambda
ハンドラー関数のリクエストの受け方・返し方が3種類
 ハンドラー関数のリクエストの受け取り方、そして、レスポンスの返し方に、以下のように複数の方式があります。
Java のシンプルな型
POJO (Plain Old Java Object) 型
ストリーム型
 それぞれでハンドラー関数の書き方が変わります。つまり、ハンドラー関数の書き方に3種類あるということです。
 「このイベントトリガーを使うならこのタイプ」というような決め方というよりも、どういったデータが送られてくるかという視点で使い分けるようです。  この状況にはこれという明確なものはないようなので、実際にJavaでLambda関数を開発する際はどの方式にするか要検討です。
 今回は、「POJO型」を採用しました。
ハンドラーの入出力タイプ (Java) – AWS Lambda
今回作ったもの
 Lambda関数のトリガーとして API Gatewayを使った、簡単なWebアプリケーションを作成しました。  POSTリクエストを送ると、”Hello”と返してくるだけのシンプルなAPIです。
サンプルコード
 作成したコードはここに置いてます。 https://github.com/mmclsntr/awslambda-javagradle
プロジェクト構成
. ├── build/ │ ├── distributions/ │ │ └── awslambda-javagradle.zip # ビルドで生成されるデプロイパッケージ │ └── ... ├── build.gradle # Gradleビルド設定ファイル ├── src/main/java/awslambda/javagradle │ ├── Greeting.java # アプリの中核となる部分 │ ├── Handler.java # Lambdaのハンドラ関数を格納 │ └── Response.java # Lambdaのレスポンスを整形 └── template.yml # CloudFormationテンプレートファイル └── その他Gradle用ファイル
コーディング
ハンドラクラス
Handler.java
package awslambda.javagradle; import java.util.Collections; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import com.amazonaws.services.lambda.runtime.Context; import com.amazonaws.services.lambda.runtime.RequestHandler; public class Handler implements RequestHandler<Map<String, Object>, Response> { private static final Logger LOG = Logger.getLogger(Handler.class.getName()); @Override public Response handleRequest(Map<String, Object> input, Context context) { LOG.info("received: " + input); LOG.setLevel(Level.INFO); Greeting greetingBody = new Greeting("Hello"); return Response.builder() .setStatusCode(200) .setObjectBody(greetingBody) .build(); } }
レスポンスクラス
Response.java
package awslambda.javagradle; import java.nio.charset.StandardCharsets; import java.util.Base64; import java.util.Collections; import java.util.Map; import org.apache.log4j.Logger; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; public class Response { private final int statusCode; private final String body; private final Map<String, String> headers; private final boolean isBase64Encoded; public Response(int statusCode, String body, Map<String, String> headers, boolean isBase64Encoded) { this.statusCode = statusCode; this.body = body; this.headers = headers; this.isBase64Encoded = isBase64Encoded; } ... }
あいさつクラス
 サンプルとしてHelloと返してくれる超シンプルなアプリケーションを作ります。
Greeting.java
package awslambda.javagradle; public class Greeting { private String greetings; public Greeting(String greetings) { this.greetings = greetings; } public String getGreetings() { return greetings; } public void setGreetings(String greetings) { this.greetings = greetings; } }
CloudFormationテンプレート
template.yml
AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: > AWS Lambda Java with Gradle Globals: Function: Timeout: 20 Resources: PostGreetingFunction: Type: AWS::Serverless::Function Properties: CodeUri: build/distributions/awslambda-javagradle.zip Handler: awslambda.javagradle.Handler::handleRequest Runtime: java8 Events: GetOrder: Type: Api Properties: Path: / Method: post Outputs: ApiEndpoint: Description: "API Gateway endpoint URL for Prod stage" Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/" PostGreetingFunction: Description: "PostGreeting Lambda Function ARN" Value: !GetAtt PostGreetingFunction.Arn
デプロイ
ビルド設定ファイル作成
build.gradle
apply plugin: 'java' repositories { mavenCentral() } sourceCompatibility = 1.8 targetCompatibility = 1.8 dependencies { compile ( 'com.amazonaws:aws-lambda-java-core:1.1.0', 'com.amazonaws:aws-lambda-java-log4j:1.0.0', 'com.amazonaws:aws-lambda-java-events:1.1.0', 'com.fasterxml.jackson.core:jackson-core:2.8.5', 'com.fasterxml.jackson.core:jackson-databind:2.8.5', 'com.fasterxml.jackson.core:jackson-annotations:2.8.5' ) } // Task for building the zip file for upload task buildZip(type: Zip) { from compileJava from processResources into('lib') { from configurations.runtime } } build.dependsOn buildZip
ビルド
Gradle コマンドでビルドします。
gradle build
AWS SAMでデプロイ
デプロイ先S3バケット作成
aws s3 mb s3://<デプロイ先S3バケット> --aws-profile=<AWSプロファイル>
パッケージ
sam packageで、上で作成したS3バケットへ実行ファイルをアップロード & デプロイ用テンプレートファイルを生成します。
sam package \ --s3-bucket <デプロイ先S3バケット名> \ --s3-prefix <デプロイ先S3フォルダ名(プレフィクス) ※任意> \ --output-template-file output.yml \ --profile <AWSプロファイル>
アウトプットとして、 output.yml ファイルが作られます。
デプロイ
sam deploy で、LambdaとAPI Gatewayをデプロイします。
sam deploy \ --template-file output.yml \ --stack-name awslambda-javagradle-greeting \ --capabilities CAPABILITY_IAM \ --profile <AWSプロファイル>
確認
AWS上にLambda関数とAPI Gatewayが作られたので、エンドポイントにPOSTリクエストを投げて見ます。
リクエスト
curl -X POST https://xxxx.execute-api.ap-northeast-1.amazonaws.com/Prod/
レスポンス
{"greetings":"Hello"}
所感
 私自身、普段はJavaを使わないのでちょっと時間がかかりましたが、簡単に作れたなという印象です。Pythonなどのスクリプト言語で作るよりも当然ながらコード量は増えますが、厳格なサーバーレス開発ができることは魅力的です。
 ハンドラー関数の書き方に複数種類あるといったJavaで書く上での特有の仕様が、今回だけでは把握しきれませんでした。実際に使う際は、その辺りも考慮しながら詳細設計したいと思います。
 また、噂通り、初期起動が遅いです (レスポンスされるまで5秒くらい)。  参照: https://cero-t.hatenadiary.jp/entry/20160106/1452090214
まとめ
 Javaを利用したLambda関数の開発の特徴やコーディング感覚をつかむことができました。  もし、サーブレットから移行するならそこそこ大規模な改修が必要と思いますが、代わりとして使えなくもない印象です。
 ランタイムがこのままJava8のみなのか、そこのサポートが少し心配です。。  API Gatewayをトリガーとしましたが、他のサービスも試して見たいと思います。
参考
https://qiita.com/kamata1729/items/8d88ea10dd3bb61fa6cc https://qiita.com/riversun/items/7fcc06617b469aed8f27
元記事はこちら
「JavaでLambda関数を書いてSAMでデプロイしてみた」
August 05, 2019 at 12:00PM
0 notes
riversuntravels · 2 months
Text
Tumblr media
Experience the best of #Rishikesh with Riversun #Travel! 🏨 Indulge in luxurious #accommodations, explore spiritual destinations, savor delicious #food, and embark on thrilling #adventures. 🚴‍♂️ Whether you need a bike to explore or a #taxi for convenience, we've got you covered. Book now for an unforgettable journey!
For more info Web: https://riversuntravel.com/ Call: 7017986103
#riversuntravel #rishikeshadventure #spiritualjourney #luxurystay #deliciousfood #adventuretravel #explorerishikesh
0 notes
entlizm · 4 years
Link
via JavaScriptタグが付けられた新着記事 - Qiita
0 notes
Photo
Tumblr media
Source: riversun, via IslamicArtDB
I am an independent, self-published author. Support this blog and the rest of my work by getting my books on Amazon.com and leaving an honest review!
130 notes · View notes
twelvebyseventyfive · 5 years
Text
Nagano region, Japan (6) Funky Château
Toyohiko (Toyo) and Micchi Kanehashi are running one of the top wineries in Nagano: Funky Château, in Aoki Village. They were working in Tokyo – Toyo as a music producer, making tunes for commercials and movie scores, and Micchi as an orthopaedist. But they loved wine, and one day wanted to make their own. They reached the point where this dream was to become reality in 2005, but they had to decide where to go. Hokkaido showed promise, but it was just too far from Tokyo – Toyo wanted to keep working in music. So, at the ages of 47 and 48 they moved to Nagano to start a winery.
Their inspiration was French and Italian wines, and specifically those made with minimal intervention. Joly, Cornelissen and Gravner were among their influences. So they decided to buy land just beside the vineyard of Manns in Higashiyama, which makes very good wines. It has very good drainage and it’s at 800 m. They now have 4 hectares here. They also have 3.5 hectares of grapes at Ueda, which is warmer, where they grow Cabernet Franc and Sauvignon, as well as Merlot and Semillon.
They were looking to have a winery surrounded by vineyards, and their current site proved to be perfect. The winery, which is beautifully designed (it’s 9 m high inside), was built in 2011. Viticulture is basically organic, with no herbicides or insecticides. They imported their plant material from Riversun in New Zealand.
The red wine barrel regime is usually 24 for reds, but Pinot Noir gets 18 months. They think that Cabernet Sauvgnon and Cabernet Franc have great potential in Ueda because they can wait as long as possible for harvest, because of the free-draining soils and low rainfall. They’d like to grow more Syrah and Sangiovese. Usually no sulfur is added until bottling, but Pinot Noir is an exception because this can be a problem wine.
We tasted through some barrels.
Semillon 2018 From a 500 litre Damy barrel. Very fine and expressive with some spice and nut notes, and lovely lemony fruit. Has nice intensity and texture. 91-93/100
Syrah 2017 Whole cluster with no added sulfites. Fresh, vivid and peppery with a bit of oak showing. Lovely intensity here. 90-92/100
Cabernet Franc 2017 Lovely brightness with black fruits and some chalkinesss. Blackcurrant notes. Nice focus and weight. 90-92/100
Merlot 2017 Good concentration here. Structured yet pretty with sweet black cherry and blackberry fruit, and a smoothness to the palate. 89-91/100
Cabernet Sauvignon 2017 From Taransaud T5 barrel. A little bit oxidative with some VA. Otherwise nice fruit. A problem wine.
Bottled wines
Funky Château Chardonnay 2015 Nagano, Japan From 9 year old vines. They think that finally the wine is expressing the terroir with this vine age. No fining or filtration. This is supple and refined with focused mealy, citrussy fruit and some stony minerality. Lovely notes of white peach and pear with good acidity and nice tension. Has lovely complexity here with layers of flavour and a savoury edge. This is very fine. 94/100
Funky Château Strate Cassée 2016 Nagano, Japan 90% Semillon, 10% Sauvignon, fermented in barrel. Amazing nose with lovely lime, spice and exotic herbs. Quite seductive. Vivid, concentrated, linear palate with powerful lime, hints of honey, and a slight oiliness to the texture, complemented by some spicy oak. High acidity. Such an impactful wine. 93/100
Funky Château Viognier 2016 Nagano, Japan From Aoki Village. It is a difficult variety to grow here, and yields erratically. But this is quite beautiful, with pear and apricot on the nose and a light but textured palate showing bright, expressive pear, apricot and spice as well as some lemony freshness. Quite lovely with good typicity. Lighter style. 92/100
Funky Château Riesling 2017 Nagano, Japan From Udea. Slightly oxidative, appley nose with nice focus to the pear and apple fruit. The palate is fresh and oxidative with herbs, lemons and baked apple character. Very appealing in this somewhat oxidative style. 89/100
Funky Château Pinot Noir 2013 Nagano, Japan This is quite distinctive with a hint of Madeira and wax on the nose, as well as notes of herbs and mint. The palate is supple with sweet cherries and subtle notes of savoury earth and herbs. There’s quite a harmony to this wine, which shows some developed characters but despite this still has fruit and freshness. There’s a seriousness to this wine, and the savoury notes are really attractive. 92/100
Funky Château Merlot 2014 Nagano, Japan Brooding and quite serious, with some savoury, spicy, earthy hints sitting under dense blackcherry and blackberry fruit. This is quite savoury, but there’s some appealing fruit here too. Complex and beautifully poised, this has nice freshness and acidity hand in hand with more developed, savoury flavours, and it’s quite delicious in a very grown up way. 93/100
Funky Château Cabernet Franc 2015 Nagano, Japan Mellow, elegant nose with some sweet cherry and plum fruit, and some subtle malty hints. The palate has lovely warm elegance with strawberries, herbs and sweet berries. It’s seamless but has good structure and acid in the background. Mature now, but no hurry to drink up: it’s in a very mellow, elegant space. This is very classy indeed: the extended elevage has worked very well, bringing harmony to the wine. 93/100
Funky Château Cabernet Franc 2016 Aoki, Chikuma River, Nagano, Japan Lovely structure and texture here: this has ripeness, smoothness and freshness, with some attractive oak playing a supporting role. It’s harmonious and elegant showing red cherry and raspberry fruit, with some silkiness and a touch of vanilla spice on the finish. Harmony is the key. 93/100
Funky Château Cabernet Sauvignon 2014 Nagano, Japan 15% Cabernet Franc in the blend here. Strongly savoury with a grippy blackcurrant fruit character. Quite tight with firm tannins and a gravelly, spicy edge. Some blackcurrant bud, here too. This is quite firm and unyielding, and I don’t think the tannins are going to resolve before the fruit goes. 87/100
from Jamie Goode's wine blog http://www.wineanorak.com:/wineblog/japan/nagano-region-japan-6-funky-chateau For Fine Wine Investment opportunities check out Twelve by Seventy Five: http://www.twelve-by-seventy-five.com/
0 notes
design03 · 5 years
Link
0 notes