tag:crieit.net,2005:https://crieit.net/users/marshmallow444/feed
marshmallow444の投稿 - Crieit
Crieitでユーザーmarshmallow444による最近の投稿
2022-03-19T23:00:31+09:00
https://crieit.net/users/marshmallow444/feed
tag:crieit.net,2005:PublicArticle/18156
2022-03-19T22:56:51+09:00
2022-03-19T23:00:31+09:00
https://crieit.net/posts/E-2022-1
【E資格】2022#1 受験してみた
<p>JDLAの<a target="_blank" rel="nofollow noopener" href="https://www.jdla.org/certificate/engineer/">E資格</a> 2022#1を受験した記録。<br />
(2022#2でシラバスが改定される前の情報なので、要注意)<br />
1ページに全部まとめようとしたらとても長くなってしまったので、<br />
一部の情報は別ページへまとめてある。</p>
<h2 id="私のスペック"><a href="#%E7%A7%81%E3%81%AE%E3%82%B9%E3%83%9A%E3%83%83%E3%82%AF">私のスペック</a></h2>
<ul>
<li>プログラミング関連
<ul>
<li>実務経験あり(約8年)</li>
<li>Pythonや機械学習関連の業務は未経験</li>
</ul></li>
<li>数学は苦手(大学教養程度)</li>
<li>Courseraの<a target="_blank" rel="nofollow noopener" href="https://www.coursera.org/learn/machine-learning">Machine Learning</a> (Stanford Univ.)の講義を受講済</li>
<li>G検定取得済(2021 #2)
<ul>
<li>↑受験したときの記録は<a target="_blank" rel="nofollow noopener" href="https://marshmallow444.github.io/tech_blog/2021/07/20/g-cert-exam.html">こちら</a></li>
</ul></li>
</ul>
<h2 id="受験した理由"><a href="#%E5%8F%97%E9%A8%93%E3%81%97%E3%81%9F%E7%90%86%E7%94%B1">受験した理由</a></h2>
<ul>
<li>比較的安価で受講できる講座を見つけた</li>
<li>E資格が<a target="_blank" rel="nofollow noopener" href="https://www.kaggle.com">Kaggle</a>に役立つという情報を、ネットで見かけた</li>
<li>AIの実装がわかるようになりたかった</li>
<li>具体的な目標がほしかった</li>
</ul>
<h2 id="受講した認定講座"><a href="#%E5%8F%97%E8%AC%9B%E3%81%97%E3%81%9F%E8%AA%8D%E5%AE%9A%E8%AC%9B%E5%BA%A7">受講した認定講座</a></h2>
<p>Study-AIの<a target="_blank" rel="nofollow noopener" href="https://ai999.careers/rabbit/">ラビット・チャレンジ</a>を受講。<br />
この講座についてのメモは<a target="_blank" rel="nofollow noopener" href="https://marshmallow444.github.io/tech_blog/2022/03/16/e-cert-rabbit-challenge.html">こちら</a></p>
<h2 id="受験までのスケジュール概要"><a href="#%E5%8F%97%E9%A8%93%E3%81%BE%E3%81%A7%E3%81%AE%E3%82%B9%E3%82%B1%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB%E6%A6%82%E8%A6%81">受験までのスケジュール概要</a></h2>
<ul>
<li>7月末〜12月末:認定講座受講</li>
<li>1月〜当日:問題集や認定講座の試験対策コンテンツを実施</li>
</ul>
<p>詳細は<a target="_blank" rel="nofollow noopener" href="https://marshmallow444.github.io/tech_blog/2022/03/16/e-cert-schedule.html">こちら</a></p>
<h2 id="認定講座修了後に勉強したこと"><a href="#%E8%AA%8D%E5%AE%9A%E8%AC%9B%E5%BA%A7%E4%BF%AE%E4%BA%86%E5%BE%8C%E3%81%AB%E5%8B%89%E5%BC%B7%E3%81%97%E3%81%9F%E3%81%93%E3%81%A8">認定講座修了後に勉強したこと</a></h2>
<ul>
<li>黒本を中心に、理解度を確認した</li>
<li>AIciaさんの動画やゼロつくを中心に、理解を深めた</li>
<li>認定講座の試験対策コンテンツで総仕上げをした</li>
</ul>
<p>勉強する際に参考になったコンテンツは<a target="_blank" rel="nofollow noopener" href="https://marshmallow444.github.io/tech_blog/2022/03/16/e-cert-study-contents.html">こちら</a></p>
<h2 id="総勉強時間"><a href="#%E7%B7%8F%E5%8B%89%E5%BC%B7%E6%99%82%E9%96%93">総勉強時間</a></h2>
<p>きちんと記録していないが、おそらく400時間以上と思われる。<br />
勉強のために、家事の最中もAIciaさんの動画の音声を聞いていたりもしたので、<br />
ちゃんと数えられない・・・</p>
<h2 id="今回の出題内容についての感想"><a href="#%E4%BB%8A%E5%9B%9E%E3%81%AE%E5%87%BA%E9%A1%8C%E5%86%85%E5%AE%B9%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6%E3%81%AE%E6%84%9F%E6%83%B3">今回の出題内容についての感想</a></h2>
<p>具体的な出題内容は守秘義務があるのでここには書けないが、<br />
ざっくりと思ったことを書いておく。</p>
<ul>
<li>特に簡単とも難しいとも思わなかった</li>
<li>黒本の内容が理解できていれば、合格できそう
<ul>
<li>受験後に黒本を見返したが、本番は黒本より簡単だったかも</li>
</ul></li>
<li>公式例題はきちんと解けるようにしておくべきだった</li>
<li>ゼロつく2の内容が役に立ったと感じる場面もあった</li>
<li>見たことのない問題も5%くらいあった (新シラバスの影響?)</li>
<li>特異値分解が出なかったのは意外だった。計算問題が思ったより少なかった</li>
<li>私の時間配分
<ul>
<li>70分間で、さっと解ける問題を一通り解答できた</li>
<li>次の30分間で、残った問題(約20問)を解答できた</li>
<li>残った20分で見直しをした(制限時間ギリギリまで)</li>
</ul></li>
<li>受験直後の手応え
<ul>
<li>例年の平均点と合格率を考えたら、たぶん受かった気はした
<ul>
<li>7割くらいは正解できたかな?という感覚だった</li>
</ul></li>
</ul></li>
</ul>
<h2 id="当日、会場で気づいたこと"><a href="#%E5%BD%93%E6%97%A5%E3%80%81%E4%BC%9A%E5%A0%B4%E3%81%A7%E6%B0%97%E3%81%A5%E3%81%84%E3%81%9F%E3%81%93%E3%81%A8">当日、会場で気づいたこと</a></h2>
<ul>
<li>同じ時間に同じ部屋でAWSの試験も行われているようだった</li>
<li>問題を最後まで一通り見ないと、問題一覧画面を表示できなかった
<ul>
<li>途中で表示しようと思ったらできなくて焦った</li>
</ul></li>
<li>ペン2本のうちの1本は、最初インクがつきにくくて焦った
<ul>
<li>(後でもう一度試したらついたので良かった)</li>
</ul></li>
<li>夕方の受験だったが、終わった時には部屋に私しかいなかった
<ul>
<li>私と同じタイミングで6人くらい入室したが、他の方々は別の試験を受けていたのかも?
<ul>
<li>隣の席の人は90分くらいで退室していった</li>
<li>1人だけ同じくらいのタイミングで退室した人がいたので、<br />
その人と私だけE資格を受けていたのかも?</li>
</ul></li>
</ul></li>
</ul>
<h2 id="当日気をつけるべき点"><a href="#%E5%BD%93%E6%97%A5%E6%B0%97%E3%82%92%E3%81%A4%E3%81%91%E3%82%8B%E3%81%B9%E3%81%8D%E7%82%B9">当日気をつけるべき点</a></h2>
<ul>
<li>試験の部屋には、私物は一切持ち込めない
<ul>
<li>勉強道具を持っていっても会場では勉強できない</li>
</ul></li>
<li>本番特有の環境に惑わされないようにする。以下のような場合があるらしい
<ul>
<li>本番用のPCが古いことがある
<ul>
<li>問題文や図などが見にくいことも</li>
</ul></li>
<li>問題文の言い回しが独特で、分かりづらい場合がある</li>
</ul></li>
<li>ペンのキャップはこまめに閉めるようにする
<ul>
<li>インクが付かなくなると焦ってしまう
<ul>
<li>交換はしてもらえるが、精神衛生上よろしくない</li>
</ul></li>
</ul></li>
<li>問題の解き方・時間配分
<ul>
<li>まずはさっと解ける問題を一通り解きつつ、全ての問題に目を通す</li>
<li>時間のかかる問題は後からじっくり解く</li>
<li>どうしても解けない問題は早めに見極めて、諦めるのも手</li>
</ul></li>
</ul>
<h2 id="事前にやるべきこと、やっておくといいこと"><a href="#%E4%BA%8B%E5%89%8D%E3%81%AB%E3%82%84%E3%82%8B%E3%81%B9%E3%81%8D%E3%81%93%E3%81%A8%E3%80%81%E3%82%84%E3%81%A3%E3%81%A6%E3%81%8A%E3%81%8F%E3%81%A8%E3%81%84%E3%81%84%E3%81%93%E3%81%A8">事前にやるべきこと、やっておくといいこと</a></h2>
<h3 id="勉強面"><a href="#%E5%8B%89%E5%BC%B7%E9%9D%A2">勉強面</a></h3>
<ul>
<li>シラバスをMarkdownやExcelの表にして、各項目の関連リンクをまとめておくとよい
<ul>
<li>試験直前の見直し時に役立つ</li>
</ul></li>
<li>黒本で要勉強箇所を洗い出し→<a target="_blank" rel="nofollow noopener" href="https://www.notion.so/ja-jp/product?utm_source=google&utm_campaign=14877655427&utm_medium=125922091577&utm_content=552465064278&utm_term=notion%20日本語&targetid=kwd-1628928191432&gclid=CjwKCAjw8sCRBhA6EiwA6_IF4ZlxoDVVXJRYvvLko84PBlmVK0HpvDUf9BrGWa9V-dUpVTTf1v_ixRoCjNQQAvD_BwE">Notion</a>にまとめたら便利だった
<ul>
<li>後から検索可能</li>
<li>動画を埋め込める</li>
</ul></li>
<li>E資格合格者の方からアドバイスを頂いたのが良かった</li>
<li>SNSで受験仲間を集めたり、他の人の勉強の様子を知ると参考になる
<ul>
<li>心が折れそうになったときにも、「苦戦しているのは自分だけじゃないんだ」と<br />
安心できることもあるかも</li>
</ul></li>
</ul>
<h3 id="その他"><a href="#%E3%81%9D%E3%81%AE%E4%BB%96">その他</a></h3>
<ul>
<li>クレジットカードを持っていない場合は、予め作っておく必要がある
<ul>
<li>受験料の支払い方法は、クレカのみ</li>
</ul></li>
<li>受験申し込みはなるべく早く済ませる方がよい
<ul>
<li>結構早く席が埋まってしまうらしい</li>
</ul></li>
<li>Pearsonの試験の<a target="_blank" rel="nofollow noopener" href="https://wsr.pearsonvue.com/demo-jp/">サンプル画面</a>を触っておくといいかも?
<ul>
<li>サイトの形式に慣れておく</li>
<li>(過去問や例題が見られるわけではない)</li>
</ul></li>
</ul>
<h2 id="受験結果"><a href="#%E5%8F%97%E9%A8%93%E7%B5%90%E6%9E%9C">受験結果</a></h2>
<p>合格。各項目の得点率は以下。</p>
<ul>
<li>応用数学:60 %</li>
<li>機械学習:67 %</li>
<li>深層学習:83 %</li>
<li>開発環境:86 %</li>
</ul>
<p>おそらく全体の得点率は8割近くかと思われる。<br />
応用数学と機械学習が思ったよりできていなくて残念だったが、<br />
平均点近くは取れていたらしい。<br />
深層学習は満足のいく出来だった。</p>
<p>今回の受験者全体の結果は<a target="_blank" rel="nofollow noopener" href="https://www.jdla.org/news/20220310001/">こちら</a>。</p>
<h2 id="受験し終わった感想"><a href="#%E5%8F%97%E9%A8%93%E3%81%97%E7%B5%82%E3%82%8F%E3%81%A3%E3%81%9F%E6%84%9F%E6%83%B3">受験し終わった感想</a></h2>
<ul>
<li>受験してよかった
<ul>
<li>勉強を始めたばかりの頃は分からないことだらけで、途中心が折れかけたこともあったが、<br />
最終的にはだいぶ知識が身についた(感じがある)</li>
</ul></li>
<li>少しAIの勉強をした方が更なるステップアップを目指す場合に、この資格は良いと思う
<ul>
<li>体系立てた内容の勉強をするのは、なかなか自力では難しい
<ul>
<li>この資格の勉強を通じて、何を勉強したらよいか目星がつく</li>
</ul></li>
</ul></li>
<li>ただE資格を取るだけでは、AI系のプログラムを書けるようにはならない
<ul>
<li>まずは今後Kaggle等でたくさん実践を積んでいきたい</li>
<li><a target="_blank" rel="nofollow noopener" href="https://aiquest.meti.go.jp/">AI Quest</a>等に参加するのもいいかも
<ul>
<li>(コーディングだけでなく、一通りの開発工程を体験できるらしい)</li>
</ul></li>
</ul></li>
<li>プロのAIエンジニアにとって、E資格の試験内容は知っていて当然のことらしい<br />
(と、どこかのサイトで読んだ)
<ul>
<li>転職活動にはあまり役に立たないかも?</li>
<li>学生さんの就活には役立つ可能性はあるかなと思う</li>
</ul></li>
</ul>
marshmallow444
tag:crieit.net,2005:PublicArticle/17720
2021-10-25T14:21:18+09:00
2021-10-25T14:22:25+09:00
https://crieit.net/posts/draw-io
draw.ioを使ってみた
<p>draw.ioという作図ツールを使ってみたメモ。</p>
<h2 id="draw.ioとは"><a href="#draw.io%E3%81%A8%E3%81%AF">draw.ioとは</a></h2>
<p>高機能作図ツール。無料で使用できる。<br />
簡単に使えて、色々な図を作成することができる。</p>
<p><img src="https://inouetetsurou.files.wordpress.com/2019/09/201406drawio.png" alt="draw.io" /><br />
(画像:<a target="_blank" rel="nofollow noopener" href="https://inouetetsurou.files.wordpress.com/2019/09/201406drawio.png">https://inouetetsurou.files.wordpress.com/2019/09/201406drawio.png</a>)</p>
<h2 id="使い方"><a href="#%E4%BD%BF%E3%81%84%E6%96%B9">使い方</a></h2>
<p>以下の3種類の方法で使用できる。</p>
<ul>
<li>ブラウザ上で作図する
<ul>
<li>以下のサイトへアクセスすると、ブラウザ上で作図することができる<br />
<a target="_blank" rel="nofollow noopener" href="https://app.diagrams.net/">https://app.diagrams.net/</a></li>
</ul></li>
<li>アプリ上で作図する
<ul>
<li>Draw.ioのGitHubのページからアプリをインストールすれば、ローカルでも作図できる<br />
<a target="_blank" rel="nofollow noopener" href="https://github.com/jgraph/drawio-desktop/releases">https://github.com/jgraph/drawio-desktop/releases</a></li>
</ul></li>
<li>VSCode上で作図する
<ul>
<li><code>Draw.io Integration</code>という拡張機能をインストールすると、VSCode上で作図できるようになる<br />
<img src="https://webbibouroku.com/wp-content/uploads/draw.io-01-1024x635.png" alt="extention" /><br />
(画像:<a target="_blank" rel="nofollow noopener" href="https://webbibouroku.com/wp-content/uploads/draw.io-01-1024x635.png">https://webbibouroku.com/wp-content/uploads/draw.io-01-1024x635.png</a>)</li>
</ul></li>
</ul>
<h3 id="操作方法"><a href="#%E6%93%8D%E4%BD%9C%E6%96%B9%E6%B3%95">操作方法</a></h3>
<p>画面左側から、パーツをドラッグ&ドロップで配置できる<br />
パーツ同士を矢印でつなぐには、パーツ上にマウスオーバーすると八方に水色の目印が出るので、それを別のパーツまでドラッグする</p>
<p><a href="https://crieit.now.sh/upload_images/4a83a25aef50acd6e3c12249275d99c961763e8923f15.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/4a83a25aef50acd6e3c12249275d99c961763e8923f15.png?mw=700" alt="20211025_2.png" /></a></p>
<p>テキストボックスには数式を入力することも可能<br />
<code>拡張</code>メニュー→<code>数式組版</code>をオンにすることで使えるようになる<br />
<code>$$ $$</code>か<code>` `</code>で囲んだ箇所が数式に変換される</p>
<h2 id="備考"><a href="#%E5%82%99%E8%80%83">備考</a></h2>
<ul>
<li>VSCodeの拡張機能では、数式を含む画像がうまくエクスポートされない
<ul>
<li>例:
<ul>
<li>テキストボックスに<code>`x_1`</code>と入力する
<ul>
<li>VSCode上では<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+x_1" alt="x_1" />と表示される</li>
<li>その図を<code>png</code>等の形式でエクスポートすると<code>`x_1`</code>と表示されてしまう</li>
</ul></li>
</ul></li>
<li>対策:ブラウザ版かアプリを使用して画像をエクスポートする</li>
</ul></li>
<li><code>.drawio.png</code>という拡張子を使うと、画像のエクスポートが不要になるらしい</li>
</ul>
<h2 id="参考"><a href="#%E5%8F%82%E8%80%83">参考</a></h2>
<ul>
<li><a target="_blank" rel="nofollow noopener" href="https://qiita.com/riku-shiru/items/5ab7c5aecdfea323ec4e">VSCodeでDraw.ioが使えるようになったらしい!</a></li>
<li><a target="_blank" rel="nofollow noopener" href="https://novnote.com/vscode-drawio-integration/600/">【備忘録】VSCode拡張機能「drawio integration」を用いてLaTeX数式を入力した画像を保存する際の注意点 & 行列の簡単な入力方法について </a></li>
</ul>
marshmallow444
tag:crieit.net,2005:PublicArticle/17704
2021-10-12T12:42:08+09:00
2021-10-12T12:42:08+09:00
https://crieit.net/posts/Docker-VSCode-Kaggle
ローカルでDocker+VSCodeを使ったKaggleの環境構築メモ
<p>以前「<a href="https://crieit.net/posts/Docker-Kaggle">Dockerを使ってKaggleの環境を構築する</a>」の手順で構築した環境にて<br />
VSCodeを使う方法がわからなかったので、新たに環境を作ってみた。<br />
手っ取り早く環境を構築したい場合は、上記記事の手順の方が手軽に試せるかも?</p>
<p>この記事の内容に沿って環境構築した:<br />
<a target="_blank" rel="nofollow noopener" href="https://qiita.com/Artela_0000/items/4b0f3c02b1e9e1b2695b">公式Dockerとvscodeを使ったKaggleの環境構築</a></p>
<h3 id="詰まった箇所"><a href="#%E8%A9%B0%E3%81%BE%E3%81%A3%E3%81%9F%E7%AE%87%E6%89%80">詰まった箇所</a></h3>
<ul>
<li>dockerのビルド時
<ul>
<li><code>--gpu</code> でエラー
<ul>
<li>macでは無理みたい</li>
</ul></li>
<li>ストレージ不足?でエラー
<ul>
<li><code>docker system prune</code> をしたら解決</li>
</ul></li>
<li>メモリ不足でエラー
<ul>
<li>dockerの設定でメモリを2GBから4GBにしたら解決</li>
<li>最低4GBは必要らしい (<a target="_blank" rel="nofollow noopener" href="https://github.com/facebook/prophet/issues/991">参考</a>)</li>
</ul></li>
</ul></li>
</ul>
<h3 id="備考"><a href="#%E5%82%99%E8%80%83">備考</a></h3>
<ul>
<li>mac OS(10.15.7)にて構築した</li>
<li><code>docker-python</code>フォルダ内に<code>.code-workspace</code>ファイルを作成しておくと便利かも</li>
</ul>
marshmallow444
tag:crieit.net,2005:PublicArticle/17678
2021-09-16T19:02:58+09:00
2021-09-16T19:02:58+09:00
https://crieit.net/posts/9d475ee4332ab019aef4f43996497c33
【ラビット・チャレンジ】応用数学
<p><a target="_blank" rel="nofollow noopener" href="https://ai999.careers/rabbit/">ラビット・チャレンジ</a>の受講レポート。</p>
<hr />
<h1 id="【線形代数学 (行列)】"><a href="#%E3%80%90%E7%B7%9A%E5%BD%A2%E4%BB%A3%E6%95%B0%E5%AD%A6+%28%E8%A1%8C%E5%88%97%29%E3%80%91">【線形代数学 (行列)】</a></h1>
<h2 id="スカラーとベクトル"><a href="#%E3%82%B9%E3%82%AB%E3%83%A9%E3%83%BC%E3%81%A8%E3%83%99%E3%82%AF%E3%83%88%E3%83%AB">スカラーとベクトル</a></h2>
<ul>
<li><strong>スカラー</strong>:普通の数</li>
<li><strong>ベクトル</strong>:「大きさ」と「向き」をもつ</li>
</ul>
<h2 id="行列"><a href="#%E8%A1%8C%E5%88%97">行列</a></h2>
<ul>
<li>スカラーを表にしたもの</li>
<li>ベクトルを並べたもの</li>
</ul>
<h2 id="連立方程式"><a href="#%E9%80%A3%E7%AB%8B%E6%96%B9%E7%A8%8B%E5%BC%8F">連立方程式</a></h2>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0Ax_1+%2B+2x_2+%3D+3%5C%5C+%0A++++2x_1+%2B+5x_2+%3D+5%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
x_1 + 2x_2 = 3\
2x_1 + 5x_2 = 5
\end{align*}
" /></p>
<p>の式を <img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0AA%5Cvec%7Bx%7D+%3D+%5Cvec%7Bb%7D%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
A\vec{x} = \vec{b}
\end{align*}
" />の形にすると、以下のようになる</p>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0A%5Cleft%28%0A++++++++%5Cbegin%7Barray%7D%7Bcc%7D%0A++++++++++++1+%26+2+%5C%5C%5C%5C++%0A++++++++++++2+%26+5%0A++++++++%5Cend%7Barray%7D%0A++++%5Cright%29%0A++++%5Cleft%28%0A++++++++%5Cbegin%7Barray%7D%7Bc%7D%0A++++++++++++x_1+%5C%5C%5C%5C++%0A++++++++++++x_2%0A++++++++%5Cend%7Barray%7D%0A++++%5Cright%29+%3D+%0A++++%5Cleft%28%0A++++++++%5Cbegin%7Barray%7D%7Bc%7D%0A++++++++++++3+%5C%5C%5C%5C++%0A++++++++++++5%0A++++++++%5Cend%7Barray%7D%0A++++%5Cright%29%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
\left(
\begin{array}{cc}
1 & 2 \\
2 & 5
\end{array}
\right)
\left(
\begin{array}{c}
x_1 \\
x_2
\end{array}
\right) =
\left(
\begin{array}{c}
3 \\
5
\end{array}
\right)
\end{align*}
" /></p>
<p>係数をまとめて表のようにした部分を<strong>行列</strong>という</p>
<h3 id="行基本変形"><a href="#%E8%A1%8C%E5%9F%BA%E6%9C%AC%E5%A4%89%E5%BD%A2">行基本変形</a></h3>
<p>= 行列の変形<br />
→行列を左からかけることで表現できる</p>
<p>手順:</p>
<p>(1) i行目をc倍する<br />
(2) s行目にt行目のc倍を加える<br />
(3) p行目とq行目を入れ替える<br />
(→連立方程式での例:2行目に<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0Ax_1%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
x_1
\end{align*}
" />, 1行目に<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0Ax_2%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
x_2
\end{align*}
" />が残ってしまっているので入れ替える)</p>
<p>参考:<a target="_blank" rel="nofollow noopener" href="https://math.005net.com/yoten/renrituKagen.php">連立方程式の解き方(加減法,代入法)</a></p>
<p>各工程で使用する行列</p>
<p>(1) i行目をc倍する<br />
+ (i, i)番目の要素をc倍する<br />
<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0AQ_%7Bi%2C+c%7D+%3D%0A++++%5Cbegin%7Bpmatrix%7D%0A++++++++1+++%26+++++++++++%26+++%26+++%26+++%26+++++++++++%26+++%5C%5C%5C%5C++%0A++++++++++++%26+%5Cddots++++%26+++%26+++%26+++%26+++++++++++%26+++%5C%5C%5C%5C++%0A++++++++++++%26+++++++++++%26+1+%26+++%26+++%26+++++++++++%26+++%5C%5C%5C%5C++%0A++++++++++++%26+++++++++++%26+++%26+c+%26+++%26+++++++++++%26+++%5C%5C%5C%5C++%0A++++++++++++%26+++++++++++%26+++%26+++%26+1+%26+++++++++++%26+++%5C%5C%5C%5C++%0A++++++++++++%26+++++++++++%26+++%26+++%26+++%26+%5Cddots++++%26+++%5C%5C%5C%5C++%0A++++++++++++%26+++++++++++%26+++%26+++%26+++%26+++++++++++%26+1+%5C%5C%5C%5C++%0A++++%5Cend%7Bpmatrix%7D%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
Q_{i, c} =
\begin{pmatrix}
1 & & & & & & \\
& \ddots & & & & & \\
& & 1 & & & & \\
& & & c & & & \\
& & & & 1 & & \\
& & & & & \ddots & \\
& & & & & & 1 \\
\end{pmatrix}
\end{align*}
" /><br />
(2) s行目にt行目のc倍を加える<br />
+ (s, t)の成分をcに変える<br />
<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0AR_%7Bs%2C+t%2C+c%7D+%3D%0A++++%5Cbegin%7Bpmatrix%7D%0A++++++++1+++%26+++++++++++%26+++%26+++++++++++%26+++%26+++++++++++%26+++%5C%5C%5C%5C++%0A++++++++++++%26+%5Cddots++++%26+++%26+++++++++++%26+++%26+++++++++++%26+++%5C%5C%5C%5C++%0A++++++++++++%26+++++++++++%26+1+%26+++++++++++%26+c+%26+++++++++++%26+++%5C%5C%5C%5C++%0A++++++++++++%26+++++++++++%26+++%26+%5Cddots++++%26+++%26+++++++++++%26+++%5C%5C%5C%5C++%0A++++++++++++%26+++++++++++%26+++%26+++++++++++%26+1+%26+++++++++++%26+++%5C%5C%5C%5C++%0A++++++++++++%26+++++++++++%26+++%26+++++++++++%26+++%26+%5Cddots++++%26+++%5C%5C%5C%5C++%0A++++++++++++%26+++++++++++%26+++%26+++++++++++%26+++%26+++++++++++%26+1+%5C%5C%5C%5C++%0A++++%5Cend%7Bpmatrix%7D%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
R_{s, t, c} =
\begin{pmatrix}
1 & & & & & & \\
& \ddots & & & & & \\
& & 1 & & c & & \\
& & & \ddots & & & \\
& & & & 1 & & \\
& & & & & \ddots & \\
& & & & & & 1 \\
\end{pmatrix}
\end{align*}
" /></p>
<p>(3) p行目とq行目を入れ替える<br />
+ (p, p), (q, q)の成分を0に変える<br />
+ (p, q), (q, p)の成分を1に変える<br />
<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0AP_%7Bp%2C+q%7D+%3D%0A++++%5Cbegin%7Bpmatrix%7D%0A++++++++1+++%26+++++++++++%26+++%26+++++++++++%26+++%26+++++++++++%26+++%5C%5C%5C%5C++%0A++++++++++++%26+%5Cddots++++%26+++%26+++++++++++%26+++%26+++++++++++%26+++%5C%5C%5C%5C++%0A++++++++++++%26+++++++++++%26+0+%26+++++++++++%26+1+%26+++++++++++%26+++%5C%5C%5C%5C++%0A++++++++++++%26+++++++++++%26+++%26+%5Cddots++++%26+++%26+++++++++++%26+++%5C%5C%5C%5C++%0A++++++++++++%26+++++++++++%26+1+%26+++++++++++%26+0+%26+++++++++++%26+++%5C%5C%5C%5C++%0A++++++++++++%26+++++++++++%26+++%26+++++++++++%26+++%26+%5Cddots++++%26+++%5C%5C%5C%5C++%0A++++++++++++%26+++++++++++%26+++%26+++++++++++%26+++%26+++++++++++%26+1+%5C%5C%5C%5C++%0A++++%5Cend%7Bpmatrix%7D%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
P_{p, q} =
\begin{pmatrix}
1 & & & & & & \\
& \ddots & & & & & \\
& & 0 & & 1 & & \\
& & & \ddots & & & \\
& & 1 & & 0 & & \\
& & & & & \ddots & \\
& & & & & & 1 \\
\end{pmatrix}
\end{align*}
" /></p>
<h3 id="単位行列"><a href="#%E5%8D%98%E4%BD%8D%E8%A1%8C%E5%88%97">単位行列</a></h3>
<p>かけてもかけられても相手が変化しない行列<br />
<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0AI+%3D+%0A++++++++%5Cbegin%7Bpmatrix%7D%0A++++++++++++1+%26+++%26+++++++++%5C%5C%5C%5C++%0A++++++++++++++%26+1+%26+++++++++%5C%5C%5C%5C++%0A++++++++++++++%26+++%26+%5Cddots++%5C%5C%5C%5C++%0A++++++++%5Cend%7Bpmatrix%7D%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
I =
\begin{pmatrix}
1 & & \\
& 1 & \\
& & \ddots \\
\end{pmatrix}
\end{align*}
" /></p>
<h3 id="逆行列"><a href="#%E9%80%86%E8%A1%8C%E5%88%97">逆行列</a></h3>
<p>まるで逆数のような働きをする行列</p>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0AAA%5E%7B-1%7D+%3D+A%5E%7B-1%7DA+%3D+I%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
AA^{-1} = A^{-1}A = I
\end{align*}
" /><br />
(「-1乗」ではなく 「<strong>inverse</strong>」)</p>
<p>掃き出し法などで求める</p>
<h4 id="逆行列が存在しない行列"><a href="#%E9%80%86%E8%A1%8C%E5%88%97%E3%81%8C%E5%AD%98%E5%9C%A8%E3%81%97%E3%81%AA%E3%81%84%E8%A1%8C%E5%88%97">逆行列が存在しない行列</a></h4>
<p>解がない/一組に定まらない連立方程式の係数を抜き出したような行列<br />
形式的には</p>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0A%5Cbegin%7Bpmatrix%7D%0A++++a+%26+b+++++++%5C%5C%5C%5C++%0A++++c+%26+d+++++++%5C%5C%5C%5C++%0A%5Cend%7Bpmatrix%7D%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
\begin{pmatrix}
a & b \\
c & d \\
\end{pmatrix}
\end{align*}
" /> という行列があったとき、<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0Aad+-+bc+%3D+0%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
ad - bc = 0
\end{align*}
" /></p>
<p>また<br />
<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0A%5Cbegin%7Bpmatrix%7D%0A++++++++a+%26+b+++++++%5C%5C%5C%5C++%0A++++++++c+%26+d+++++++%5C%5C%5C%5C++%0A++++%5Cend%7Bpmatrix%7D+%3D%0A++++%5Cbegin%7Bpmatrix%7D%0A++++++++%5Cvec%7Bv_1%7D+++++++%5C%5C%5C%5C++%0A++++++++%5Cvec%7Bv_2%7D+++++++%5C%5C%5C%5C++%0A++++%5Cend%7Bpmatrix%7D%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
\begin{pmatrix}
a & b \\
c & d \\
\end{pmatrix} =
\begin{pmatrix}
\vec{v_1} \\
\vec{v_2} \\
\end{pmatrix}
\end{align*}
" /><br />
と考えたとき、二つのベクトルに囲まれた<br />
<code>平行四辺形の面積 = 0</code><br />
の場合は逆行列が存在しない</p>
<h3 id="行列式(determinant)"><a href="#%E8%A1%8C%E5%88%97%E5%BC%8F%28determinant%29">行列式(determinant)</a></h3>
<p>上記の平行四辺形の面積が逆行列の有無を示す<br />
これを<br />
<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0A%5Cbegin%7Bvmatrix%7D%0A++++++++a+%26+b+++++++%5C%5C%5C%5C++%0A++++++++c+%26+d+++++++%5C%5C%5C%5C++%0A++++%5Cend%7Bvmatrix%7D+%3D%0A++++%5Cbegin%7Bvmatrix%7D%0A++++++++%5Cvec%7Bv_1%7D+++++++%5C%5C%5C%5C++%0A++++++++%5Cvec%7Bv_2%7D+++++++%5C%5C%5C%5C++%0A++++%5Cend%7Bvmatrix%7D%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
\begin{vmatrix}
a & b \\
c & d \\
\end{vmatrix} =
\begin{vmatrix}
\vec{v_1} \\
\vec{v_2} \\
\end{vmatrix}
\end{align*}
" /><br />
と表し、<strong>逆行列</strong>と呼ぶ</p>
<h4 id="特徴"><a href="#%E7%89%B9%E5%BE%B4">特徴</a></h4>
<ul>
<li>同じ行ベクトルが含まれていると行列式は0</li>
<li>1つのベクトルが<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0A%5Clambda%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
\lambda
\end{align*}
" />倍されると行列式は<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0A%5Clambda%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
\lambda
\end{align*}
" />倍される</li>
<li>他の成分が全部同じで<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0Ai%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
i
\end{align*}
" />番目のベクトルだけが違う場合、行列式の足し合わせになる</li>
</ul>
<p>3つ以上のベクトルからできている行列式は展開できる</p>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0A%5Cbegin%7Bvmatrix%7D%0A++++++++%5Cvec%7Bv_1%7D+%5C%5C%5C%5C++%0A++++++++%5Cvec%7Bv_2%7D+%5C%5C%5C%5C++%0A++++++++%5Cvec%7Bv_3%7D+%0A++++%5Cend%7Bvmatrix%7D+%3D+%0A++++%5Cbegin%7Bvmatrix%7D%0A++++++++a+%26+b+%26+c+%5C%5C%5C%5C++%0A++++++++d+%26+e+%26+f+%5C%5C%5C%5C++%0A++++++++g+%26+h+%26+i+%0A++++%5Cend%7Bvmatrix%7D+%3D+%0A++++%5Cbegin%7Bvmatrix%7D%0A++++++++a+%26+b+%26+c+%5C%5C%5C%5C++%0A++++++++0+%26+e+%26+f+%5C%5C%5C%5C++%0A++++++++0+%26+h+%26+i+%0A++++%5Cend%7Bvmatrix%7D+%2B+%0A++++%5Cbegin%7Bvmatrix%7D%0A++++++++0+%26+b+%26+c+%5C%5C%5C%5C++%0A++++++++d+%26+e+%26+f+%5C%5C%5C%5C++%0A++++++++0+%26+h+%26+i+%0A++++%5Cend%7Bvmatrix%7D+%2B+%0A++++%5Cbegin%7Bvmatrix%7D%0A++++++++0+%26+b+%26+c+%5C%5C%5C%5C++%0A++++++++0+%26+e+%26+f+%5C%5C%5C%5C++%0A++++++++g+%26+h+%26+i+%0A++++%5Cend%7Bvmatrix%7D%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
\begin{vmatrix}
\vec{v_1} \\
\vec{v_2} \\
\vec{v_3}
\end{vmatrix} =
\begin{vmatrix}
a & b & c \\
d & e & f \\
g & h & i
\end{vmatrix} =
\begin{vmatrix}
a & b & c \\
0 & e & f \\
0 & h & i
\end{vmatrix} +
\begin{vmatrix}
0 & b & c \\
d & e & f \\
0 & h & i
\end{vmatrix} +
\begin{vmatrix}
0 & b & c \\
0 & e & f \\
g & h & i
\end{vmatrix}
\end{align*}
" /><br />
<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0A%3D+a%0A++++%5Cbegin%7Bvmatrix%7D%0A++++++++e+%26+f+%5C%5C%5C%5C++%0A++++++++h+%26+i+%0A++++%5Cend%7Bvmatrix%7D+-+%0A++++d%0A++++%5Cbegin%7Bvmatrix%7D%0A++++++++b+%26+c+%5C%5C%5C%5C++%0A++++++++h+%26+i+%0A++++%5Cend%7Bvmatrix%7D+%2B%0A++++g%0A++++%5Cbegin%7Bvmatrix%7D%0A++++++++b+%26+c+%5C%5C%5C%5C++%0A++++++++e+%26+f+%0A++++%5Cend%7Bvmatrix%7D%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
= a
\begin{vmatrix}
e & f \\
h & i
\end{vmatrix} -
d
\begin{vmatrix}
b & c \\
h & i
\end{vmatrix} +
g
\begin{vmatrix}
b & c \\
e & f
\end{vmatrix}
\end{align*}
" /></p>
<h4 id="行列式の求め方"><a href="#%E8%A1%8C%E5%88%97%E5%BC%8F%E3%81%AE%E6%B1%82%E3%82%81%E6%96%B9">行列式の求め方</a></h4>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0A%5Cbegin%7Bvmatrix%7D%0A++++++++a+%26+b+++++++%5C%5C%5C%5C++%0A++++++++c+%26+d+++++++%5C%5C%5C%5C++%0A++++%5Cend%7Bvmatrix%7D+%3D+ad+-+bc%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
\begin{vmatrix}
a & b \\
c & d \\
\end{vmatrix} = ad - bc
\end{align*}
" /><br />
3つ以上のベクトルでできている場合は展開して求める</p>
<p>参考:<a target="_blank" rel="nofollow noopener" href="https://risalc.info/src/determinant-formulas.html">行列式の基本的な性質と公式</a></p>
<hr />
<h1 id="【線形代数学 (固有値)】"><a href="#%E3%80%90%E7%B7%9A%E5%BD%A2%E4%BB%A3%E6%95%B0%E5%AD%A6+%28%E5%9B%BA%E6%9C%89%E5%80%A4%29%E3%80%91">【線形代数学 (固有値)】</a></h1>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0AA%5Cvec%7Bx%7D+%3D+%5Clambda%5Cvec%7Bx%7D%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
A\vec{x} = \lambda\vec{x}
\end{align*}
" /><br />
が成り立つような行列A, 特殊なベクトル<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0A%5Cvec%7Bx%7D%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
\vec{x}
\end{align*}
" />, 右辺の係数<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0A%5Clambda%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
\lambda
\end{align*}
" />があるとき、</p>
<ul>
<li><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0A%5Cvec%7Bx%7D%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
\vec{x}
\end{align*}
" />: 行列Aに対する固有ベクトル
<ul>
<li>一つに定まらない</li>
<li>「<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0A%5Cvec%7Bx%7D%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
\vec{x}
\end{align*}
" />の定数倍」のように表す</li>
</ul></li>
<li><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0A%5Clambda%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
\lambda
\end{align*}
" />: 行列Aに対する固有値
<ul>
<li>一つに定まる</li>
</ul></li>
</ul>
<h4 id="固有値と固有ベクトルの求め方:"><a href="#%E5%9B%BA%E6%9C%89%E5%80%A4%E3%81%A8%E5%9B%BA%E6%9C%89%E3%83%99%E3%82%AF%E3%83%88%E3%83%AB%E3%81%AE%E6%B1%82%E3%82%81%E6%96%B9%EF%BC%9A">固有値と固有ベクトルの求め方:</a></h4>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0A%5Cbegin%7Bvmatrix%7D%0A%09++++A+-+%5Clambda+I+%3D+0%09%5C%5C%5C%5C++%0A%09%5Cend%7Bvmatrix%7D%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
\begin{vmatrix}
A - \lambda I = 0 \\
\end{vmatrix}
\end{align*}
" /><br />
となるような<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0A%5Clambda%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
\lambda
\end{align*}
" />を求め、<br />
<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0AA%0A%09%5Cbegin%7Bpmatrix%7D%0A%09%09x_1%5C%5C%5C%5C++%0A++++++++x_2%0A%09%5Cend%7Bpmatrix%7D%0A++++%3D+%5Clambda%0A++++%5Cbegin%7Bpmatrix%7D%0A%09%09x_1%5C%5C%5C%5C++%0A++++++++x_2%0A%09%5Cend%7Bpmatrix%7D%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
A
\begin{pmatrix}
x_1\\
x_2
\end{pmatrix}
= \lambda
\begin{pmatrix}
x_1\\
x_2
\end{pmatrix}
\end{align*}
" /><br />
を解いて<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+x_1%0A" alt="x_1
" />と<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+x_2%0A" alt="x_2
" />の比を求める</p>
<h3 id="固有値分解"><a href="#%E5%9B%BA%E6%9C%89%E5%80%A4%E5%88%86%E8%A7%A3">固有値分解</a></h3>
<ul>
<li>ある実数を正方形に並べた行列<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+A%0A" alt="A
" /></li>
<li><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+A%0A" alt="A
" />の固有値<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Clambda_1" alt="\lambda_1" />, <img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Clambda_2" alt="\lambda_2" />, ...</li>
<li><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+A%0A" alt="A
" />の固有ベクトル<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cvec%7Bv_1%7D" alt="\vec{v_1}" />, <img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cvec%7Bv_2%7D" alt="\vec{v_2}" />, ...</li>
</ul>
<p>があるとき、固有値を対角線上に並べた行列<br />
<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5CLambda+%3D+%0A%09%5Cbegin%7Bpmatrix%7D%0A%09%09%5Clambda_1+%26++%26++%5C%5C%5C%5C++%0A+++++++++%26+%5Clambda_2+%26+%5C%5C%5C%5C++%0A+++++++++%26+%26+%5Cddots%0A%09%5Cend%7Bpmatrix%7D" alt="\Lambda =
\begin{pmatrix}
\lambda_1 & & \\
& \lambda_2 & \\
& & \ddots
\end{pmatrix}" /><br />
と、それに対応する固有ベクトルを並べた行列<br />
<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+V+%3D+%0A%09%5Cbegin%7Bpmatrix%7D%0A+++++++++%26+%26+%5C%5C%5C%5C++%0A%09%09%5Cvec%7Bv_1%7D+%26+%5Cvec%7Bv_2%7D+%26+%5Ccdots+%5C%5C%5C%5C++%0A+++++++++%26+%26+%5C%5C%5C%5C++%0A%09%5Cend%7Bpmatrix%7D" alt="V =
\begin{pmatrix}
& & \\
\vec{v_1} & \vec{v_2} & \cdots \\
& & \\
\end{pmatrix}" /><br />
を用意したとき、<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+AV+%3D+V%5CLambda" alt="AV = V\Lambda" />となる<br />
変形すると<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+A+%3D+V+%5CLambda+V%5E%7B-1%7D" alt="A = V \Lambda V^{-1}" /><br />
+ <strong>固有値分解</strong>:正方形の行列を上記のような3つの行列の積に分解すること<br />
+ 利点:行列の累乗が容易になる など<br />
+ <img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5CLambda" alt="\Lambda" />の中身は、<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Clambda" alt="\lambda" />を小さい順or大きい順に並べることが多い</p>
<h3 id="特異値分解"><a href="#%E7%89%B9%E7%95%B0%E5%80%A4%E5%88%86%E8%A7%A3">特異値分解</a></h3>
<p>正方行列以外の行列において<br />
<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0AM%5Cvec%7Bv%7D+%3D+%5Csigma%5Cvec%7Bu%7D+%5C%5C++++%0AM%5ET%5Cvec%7Bu%7D+%3D+%5Csigma%5Cvec%7Bv%7D%0A%5Cend%7Balign%2A%7D" alt="\begin{align*}
M\vec{v} = \sigma\vec{u} \
M^T\vec{u} = \sigma\vec{v}
\end{align*}" /><br />
となる特殊な単位ベクトルがある場合、<strong>特異値分解</strong>が可能<br />
<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+M+%3D+USV%5ET" alt="M = USV^T" /></p>
<ul>
<li><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+U" alt="U" />や<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+V" alt="V" />は直行行列
<ul>
<li>複素数を要素に持つ場合はユニタリ行列</li>
</ul></li>
<li><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+S" alt="S" /> = Sigma</li>
</ul>
<h4 id="特異値の求め方"><a href="#%E7%89%B9%E7%95%B0%E5%80%A4%E3%81%AE%E6%B1%82%E3%82%81%E6%96%B9">特異値の求め方</a></h4>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+MV+%3D+US" alt="MV = US" /> → <img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+M+%3D+USV%5ET" alt="M = USV^T" /><br />
<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+M%5ETU+%3D+VS%5ET" alt="M^TU = VS^T" /> → <img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+M%5ET+%3D+VS%5ETU%5ET" alt="M^T = VS^TU^T" /><br />
これらの積は<br />
<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+MM%5ET+%3D+USV%5ETVS%5ETU%5ET+%3D+USS%5ETU%5ET" alt="MM^T = USV^TVS^TU^T = USS^TU^T" /><br />
(<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+MM%5ET" alt="MM^T" />で正方行列を作って固有値分解する)</p>
<h4 id="特異値分解の利用例"><a href="#%E7%89%B9%E7%95%B0%E5%80%A4%E5%88%86%E8%A7%A3%E3%81%AE%E5%88%A9%E7%94%A8%E4%BE%8B">特異値分解の利用例</a></h4>
<ul>
<li>画像データの圧縮</li>
<li>機械学習の前処理
<ul>
<li>特異値の大きい部分が似ている画像どうしは、画像の特徴も似ている</li>
<li>画像の分類などができる</li>
</ul></li>
</ul>
<hr />
<h1 id="【統計学1】"><a href="#%E3%80%90%E7%B5%B1%E8%A8%88%E5%AD%A61%E3%80%91">【統計学1】</a></h1>
<h2 id="集合とは?"><a href="#%E9%9B%86%E5%90%88%E3%81%A8%E3%81%AF%EF%BC%9F">集合とは?</a></h2>
<p>→ものの集まり</p>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+S+%3D+%5C%7B+a%2C+b%2C+c%2C+d%2C+e%2C+f%2C+g+%5C%7D" alt="S = { a, b, c, d, e, f, g }" /><br />
<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+a+%5Cin+S" alt="a \in S" /> ← <img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+a" alt="a" />は集合<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+S" alt="S" />の要素<br />
<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+h+%5Cnotin+S" alt="h \notin S" /> ← <img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+h" alt="h" />は集合<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+S" alt="S" />の要素ではない<br />
(「要素」は「元(げん)」と呼ばれることもある)</p>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+M+%3D+%5C%7B+c%2C+d%2C+e+%5C%7D" alt="M = { c, d, e }" /><br />
<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+M+%5Csubset+S" alt="M \subset S" /> ← <img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+M" alt="M" />は<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+S" alt="S" />の一部</p>
<ul>
<li>和集合 <img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+A+%5Ccap+B" alt="A \cap B" /></li>
<li>共通部分 <img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+A+%5Ccup+B" alt="A \cup B" /></li>
<li>絶対補 <img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+U+%5Csetminus+A+%3D+%5Cbar%7BA%7D" alt="U \setminus A = \bar{A}" /></li>
<li>相対補 <img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+B+%5Csetminus+A" alt="B \setminus A" /></li>
</ul>
<h2 id="確率"><a href="#%E7%A2%BA%E7%8E%87">確率</a></h2>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+P%28A%29+%3D+%5Cdfrac%7Bn%28A%29%7D%7Bn%28U%29%7D" alt="P(A) = \dfrac{n(A)}{n(U)}" /></p>
<ul>
<li>頻度確率(客観確率):発生する頻度</li>
<li>ベイズ確率(主観確率):信念の度合い</li>
</ul>
<h4 id="条件付き確率"><a href="#%E6%9D%A1%E4%BB%B6%E4%BB%98%E3%81%8D%E7%A2%BA%E7%8E%87">条件付き確率</a></h4>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+P%28B+%7C+A%29" alt="P(B | A)" /> ←<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+A" alt="A" />という条件のもと、<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+B" alt="B" />である<br />
<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+P%28B+%7C+A%29+%3D+%5Cdfrac%7BP%28A+%5Ccap+B%29%7D%7BP%28B%29%7D+%3D+%5Cdfrac%7Bn%28A+%5Ccap+B%29%7D%7Bn%28B%29%7D" alt="P(B | A) = \dfrac{P(A \cap B)}{P(B)} = \dfrac{n(A \cap B)}{n(B)}" /></p>
<h4 id="独立な事象の同時確率"><a href="#%E7%8B%AC%E7%AB%8B%E3%81%AA%E4%BA%8B%E8%B1%A1%E3%81%AE%E5%90%8C%E6%99%82%E7%A2%BA%E7%8E%87">独立な事象の同時確率</a></h4>
<p>事象Aと事象Bに因果関係がない場合、<br />
<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+P%28A+%5Ccap+B%29+%3D+P%28A%29P%28B%7CA%29+%3D+P%28A%29P%28B%29" alt="P(A \cap B) = P(A)P(B|A) = P(A)P(B)" /></p>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+P%28A+%5Ccup+B%29+%3D+P%28A%29+%2B+P%28B%29+-+P%28A+%5Ccap+B%29" alt="P(A \cup B) = P(A) + P(B) - P(A \cap B)" /></p>
<h4 id="ベイズ則"><a href="#%E3%83%99%E3%82%A4%E3%82%BA%E5%89%87">ベイズ則</a></h4>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+P%28A%29P%28B%7CA%29+%3D+P%28B%29P%28A%7CB%29" alt="P(A)P(B|A) = P(B)P(A|B)" /></p>
<hr />
<h1 id="【統計学2】"><a href="#%E3%80%90%E7%B5%B1%E8%A8%88%E5%AD%A62%E3%80%91">【統計学2】</a></h1>
<ul>
<li><strong>記述統計</strong>:集団の性質を要約し記述する</li>
<li><p><strong>推測統計</strong>:集団から一部を取り出し(標本)、元の集団(母集団)の性質を推測する</p></li>
<li><p><strong>確率変数</strong>:事象と結び付けられた数値</p></li>
<li><strong>確率分布</strong>:事象の発生する確率の分布</li>
</ul>
<h4 id="期待値"><a href="#%E6%9C%9F%E5%BE%85%E5%80%A4">期待値</a></h4>
<p>その分布における、確率変数の<br />
<em>平均の値</em> または <em>「ありえそう」な値</em></p>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+E%28f%29+%3D+%5Csum_%7Bk%3D1%7D%5E%7Bn%7DP%28X+%3D+x_%7Bk%7D%29f%28X+%3D+x_%7Bk%7D%29%0A" alt="E(f) = \sum_{k=1}^{n}P(X = x_{k})f(X = x_{k})
" /></p>
<p>連続する値なら、</p>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+E%28f%29+%3D+%5Cint+P%28X+%3D+x%29f%28X+%3D+x%29dx" alt="E(f) = \int P(X = x)f(X = x)dx" /></p>
<h4 id="分散"><a href="#%E5%88%86%E6%95%A3">分散</a></h4>
<p>データの散らばり具合</p>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+Var%28f%29+%3D+E%0A++++++++%5Cbiggl%28++%0A++++++++++++%5CBigl%28%0A++++++++++++++++f_%7B+%28X+%3D+x%29+%7D+-+E_%7B+%28f%29+%7D%0A++++++++++++%5CBigr%29+%5E+2%0A++++++++%5Cbiggr%29+%3D+E%0A++++++++%5CBigl%28%0A++++++++++++f+%5E+2+_%7B+%28X+%3D+x%29+%7D%0A++++++++%5CBigr%29+-+%0A++++++++%5CBigl%28%0A++++++++++++E+_%7B+%28f%29+%7D%0A++++++++%5CBigr%29+%5E+2" alt="Var(f) = E
\biggl(
\Bigl(
f_{ (X = x) } - E_{ (f) }
\Bigr) ^ 2
\biggr) = E
\Bigl(
f ^ 2 _{ (X = x) }
\Bigr) -
\Bigl(
E _{ (f) }
\Bigr) ^ 2" /><br />
→(二乗の平均) - (平均の二乗)</p>
<h4 id="共分散"><a href="#%E5%85%B1%E5%88%86%E6%95%A3">共分散</a></h4>
<p>2つのデータ系列の傾向の違い</p>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+Cov%28f%2C+g%29+%3D+E%0A++++++++%5Cbiggl%28++%0A++++++++++++%5CBigl%28%0A++++++++++++++++f+_%7B+%28X+%3D+x%29+%7D+-+E%28f%29%0A++++++++++++%5CBigr%29%0A++++++++++++%5CBigl%28%0A++++++++++++++++g+_%7B+%28Y+%3D+y%29+%7D+-+E%28g%29%0A++++++++++++%5CBigr%29%0A++++++++%5Cbiggr%29+%3D+E%28fg%29+-+E%28f%29E%28g%29" alt="Cov(f, g) = E
\biggl(
\Bigl(
f _{ (X = x) } - E(f)
\Bigr)
\Bigl(
g _{ (Y = y) } - E(g)
\Bigr)
\biggr) = E(fg) - E(f)E(g)" /></p>
<h4 id="標準偏差"><a href="#%E6%A8%99%E6%BA%96%E5%81%8F%E5%B7%AE">標準偏差</a></h4>
<p>分散の平方根</p>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Csigma+%3D+%5Csqrt%7B+Var%28f%29+%7D%0A++++%3D+%5Csqrt%7B+%0A++++++++E%0A++++++++%5Cbiggl%28++%0A++++++++++++%5CBigl%28%0A++++++++++++++++f_%7B+%28X+%3D+x%29+%7D+-+E_%7B+%28f%29+%7D%0A++++++++++++%5CBigr%29+%5E+2%0A++++++++%5Cbiggr%29%0A+++++%7D" alt="\sigma = \sqrt{ Var(f) }
= \sqrt{
E
\biggl(
\Bigl(
f_{ (X = x) } - E_{ (f) }
\Bigr) ^ 2
\biggr)
}" /></p>
<h3 id="様々な確率分布"><a href="#%E6%A7%98%E3%80%85%E3%81%AA%E7%A2%BA%E7%8E%87%E5%88%86%E5%B8%83">様々な確率分布</a></h3>
<h4 id="ベルヌーイ分布"><a href="#%E3%83%99%E3%83%AB%E3%83%8C%E3%83%BC%E3%82%A4%E5%88%86%E5%B8%83">ベルヌーイ分布</a></h4>
<p>コイントスのイメージ(表か裏か?)<br />
<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+P%28X%7C%5Cmu%29+%3D+%5Cmu+%5E+x+%281+-+%5Cmu%29+%5E+%7B1-x%7D" alt="P(X|\mu) = \mu ^ x (1 - \mu) ^ {1-x}" /></p>
<h4 id="マルチヌーイ(カテゴリカル)分布"><a href="#%E3%83%9E%E3%83%AB%E3%83%81%E3%83%8C%E3%83%BC%E3%82%A4%28%E3%82%AB%E3%83%86%E3%82%B4%E3%83%AA%E3%82%AB%E3%83%AB%29%E5%88%86%E5%B8%83">マルチヌーイ(カテゴリカル)分布</a></h4>
<p>サイコロを転がすイメージ(出る目が3種類以上)</p>
<h4 id="二項分布"><a href="#%E4%BA%8C%E9%A0%85%E5%88%86%E5%B8%83">二項分布</a></h4>
<p>ベルヌーイ分布の多試行版<br />
<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+P%28x%7C%5Clambda%2C+n%29+%3D%5Cdfrac%7Bn%21%7D%7Bx%21%28n+-+x%29%21%7D+%5Clambda+%5E+x%281+-+%5Clambda%29+%5E+%7Bn-x%7D" alt="P(x|\lambda, n) =\dfrac{n!}{x!(n - x)!} \lambda ^ x(1 - \lambda) ^ {n-x}" /></p>
<h4 id="ガウス分布"><a href="#%E3%82%AC%E3%82%A6%E3%82%B9%E5%88%86%E5%B8%83">ガウス分布</a></h4>
<p>釣鐘型の連続分布<br />
→指数関数を2つ並べたような形<br />
→真の分布がわからなくても、大体の予想がつく</p>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cmathcal%7BN%7D%28x%3B+%5Cmu%2C+%5Csigma%5E2%29+%3D+%5Csqrt%0A++++%7B+%0A++++++++%5Cdfrac%7B1%7D%7B2+%5Cpi+%5Csigma%5E2%7D%0A++++%7D+%5Cmathrm%7Bexp%7D%0A++++%5CBigl%28%0A++++++++-+%5Cdfrac%7B1%7D%7B2+%5Csigma+%5E+2%7D%28x+-+%5Cmu%29+%5E+2%0A++++%5CBigr%29" alt="\mathcal{N}(x; \mu, \sigma^2) = \sqrt
{
\dfrac{1}{2 \pi \sigma^2}
} \mathrm{exp}
\Bigl(
- \dfrac{1}{2 \sigma ^ 2}(x - \mu) ^ 2
\Bigr)" /></p>
<h2 id="推定"><a href="#%E6%8E%A8%E5%AE%9A">推定</a></h2>
<p>母集団を特徴づける <strong>母数</strong> を統計学的に推測すること<br />
→母数:パラメータ(平均など)</p>
<ul>
<li><strong>点推定</strong>:平均値などを一つの値に推定</li>
<li><strong>区間推定</strong>:平均値などが存在する範囲を推定</li>
<li><strong>推定量</strong>(推定関数 / estimator):パラメータ推定のための計算方法、計算式
<ul>
<li>表記例:<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Chat%7B%5Ctheta%7D%28x%29" alt="\hat{\theta}(x)" /></li>
</ul></li>
<li><strong>推定値</strong>(estimate):実際に試行した結果から計算した値
<ul>
<li>表記例:<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Chat%7B%5Ctheta%7D" alt="\hat{\theta}" /></li>
</ul></li>
</ul>
<h3 id="点推定の例"><a href="#%E7%82%B9%E6%8E%A8%E5%AE%9A%E3%81%AE%E4%BE%8B">点推定の例</a></h3>
<h4 id="標本平均"><a href="#%E6%A8%99%E6%9C%AC%E5%B9%B3%E5%9D%87">標本平均</a></h4>
<p>母集団から取り出した標本の平均値</p>
<ul>
<li><strong>一致性</strong>:サンプル数が大きいほど母集団の値に近くなる</li>
<li><strong>不偏性</strong>:サンプル数がいくつでも、その期待値は母集団の値と同様
<ul>
<li><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+E%28%5Chat%7B%5Ctheta%7D%29+%3D+%5Ctheta" alt="E(\hat{\theta}) = \theta" /></li>
</ul></li>
</ul>
<h4 id="標本分散"><a href="#%E6%A8%99%E6%9C%AC%E5%88%86%E6%95%A3">標本分散</a></h4>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Chat%7B%5Csigma%7D+%5E+2+%3D+%5Cdfrac%7B1%7D%7Bn%7D+%5Csum_%7Bi%3D1%7D%5E%7Bn%7D%28x_i+-++%5Cbar%7Bx%7D%29+%5E+2" alt="\hat{\sigma} ^ 2 = \dfrac{1}{n} \sum_{i=1}^{n}(x_i - \bar{x}) ^ 2" /></p>
<h4 id="普遍分散"><a href="#%E6%99%AE%E9%81%8D%E5%88%86%E6%95%A3">普遍分散</a></h4>
<p>→標本分散のばらつきを修正(サンプル数に応じて変わるのを防ぐ)</p>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+s+%5E+2+%3D+%5Cdfrac%7Bn%7D%7Bn+-+1%7D+%5Ctimes+%5Cdfrac%7B1%7D%7Bn%7D+%5Csum_%7Bi%3D1%7D%5E%7Bn%7D+%28x_i+-+%5Cbar%7Bx%7D%29+%5E+2+%3D+%5Cdfrac%7B1%7D%7Bn-1%7D%28x_i+-+%5Cbar%7Bx%7D%29+%5E+2" alt="s ^ 2 = \dfrac{n}{n - 1} \times \dfrac{1}{n} \sum_{i=1}^{n} (x_i - \bar{x}) ^ 2 = \dfrac{1}{n-1}(x_i - \bar{x}) ^ 2" /></p>
<h2 id="情報科学"><a href="#%E6%83%85%E5%A0%B1%E7%A7%91%E5%AD%A6">情報科学</a></h2>
<h4 id="自己情報量"><a href="#%E8%87%AA%E5%B7%B1%E6%83%85%E5%A0%B1%E9%87%8F">自己情報量</a></h4>
<div class="table-responsive"><table>
<thead>
<tr>
<th>対数の底</th>
<th>単位</th>
</tr>
</thead>
<tbody>
<tr>
<td>2</td>
<td>bit</td>
</tr>
<tr>
<td>e (ネイピア)</td>
<td>nat (natural)</td>
</tr>
</tbody>
</table></div>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+I%28x%29+%3D+-+%5Cmathrm%7Blog%7D%28P%28x%29%29+%3D+%5Cmathrm%7Blog%7D%28W%28x%29%29" alt="I(x) = - \mathrm{log}(P(x)) = \mathrm{log}(W(x))" /></p>
<p>ON/OFFのスイッチで情報を伝えるとき、情報の種類数に対して必要なスイッチの数は?<br />
→事象の数<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+W" alt="W" />のlogを取ることで求められる</p>
<h4 id="シャノンエントロピ"><a href="#%E3%82%B7%E3%83%A3%E3%83%8E%E3%83%B3%E3%82%A8%E3%83%B3%E3%83%88%E3%83%AD%E3%83%94">シャノンエントロピ</a></h4>
<p>= <strong>微分エントロピ</strong> (微分しているわけではない)<br />
自己情報量の期待値 (情報の珍しさの平均値みたいなもの)</p>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+H%28x%29+%3D+E%28+I%28x%29+%29+%5C%5C%5C%5C++%0A++++%3D+-E+%5CBigl%28+%5Cmathrm%7Blog%7D+%5Cbigl%28P%28x%29+%5Cbigr%29+%5CBigr%29+%5C%5C%5C%5C++%0A++++%3D+-+%5Csum+%5CBigl%28+P%28x%29+%5Cmathrm%7Blog%7D+%5Cbigl%28P%28x%29+%5Cbigr%29+%5CBigr%29" alt="H(x) = E( I(x) ) \\
= -E \Bigl( \mathrm{log} \bigl(P(x) \bigr) \Bigr) \\
= - \sum \Bigl( P(x) \mathrm{log} \bigl(P(x) \bigr) \Bigr)" /></p>
<h4 id="カルバック・ライブラー ダイバージェンス"><a href="#%E3%82%AB%E3%83%AB%E3%83%90%E3%83%83%E3%82%AF%E3%83%BB%E3%83%A9%E3%82%A4%E3%83%96%E3%83%A9%E3%83%BC+%E3%83%80%E3%82%A4%E3%83%90%E3%83%BC%E3%82%B8%E3%82%A7%E3%83%B3%E3%82%B9">カルバック・ライブラー ダイバージェンス</a></h4>
<p>同じ事象・確率変数における異なる確率分布<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+P" alt="P" />, <img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+Q" alt="Q" />の違いを表す<br />
→想定していた確率分布:<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+Q" alt="Q" />、実際の確率分布:<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+P" alt="P" /><br />
距離のようなもの(厳密には違う)<br />
例:普通のコインと不正なコインの、表と裏が出る確率の違い</p>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+D_%7BKL%7D%28P%7C%7CQ%29+%3D+%5Coverbrace%7B%0A++++++++%5Cmathbb%7BE%7D_%7Bx+%5Csim+P%7D%0A++++%7D%5E%7B%281%29%7D+%5Cbiggl%5B+%0A++++++++%5Coverbrace%7B+%0A++++++++++++%5Cmathrm%7Blog%7D+%5Cdfrac%7BP%28x%29%7D%7BQ%28x%29%7D+%0A++++++++%7D%5E%7B%282%29%7D%0A++++%5Cbiggr%5D%0A%3D+%5Coverbrace%7B+%0A+++++++++%5Cmathbb%7BE%7D_%7Bx+%5Csim+P%7D+%0A++++%7D%5E%7B%281%29%7D+%5Cbigl%5B+%0A++++++++%5Coverbrace%7B+%0A++++++++++++%5Cmathrm%7Blog%7DP%28x%29+-+%5Cmathrm%7Blog%7DQ%28x%29+%0A++++++++%7D%5E%7B%282%29%7D%0A++++%5Cbigr%5D" alt="D_{KL}(P||Q) = \overbrace{
\mathbb{E}_{x \sim P}
}^{(1)} \biggl[
\overbrace{
\mathrm{log} \dfrac{P(x)}{Q(x)}
}^{(2)}
\biggr]
= \overbrace{
\mathbb{E}_{x \sim P}
}^{(1)} \bigl[
\overbrace{
\mathrm{log}P(x) - \mathrm{log}Q(x)
}^{(2)}
\bigr]" /></p>
<p><code>(1)</code> について、</p>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+E+%5Cbigl%28+f%28x%29+%5Cbigr%29+%3D+%5Csum_%7Bx%7D+P%28x%29f%28x%29" alt="E \bigl( f(x) \bigr) = \sum_{x} P(x)f(x)" /></p>
<p><code>(2)</code>について、</p>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+I%28Q%28x%29%29+-+I%28P%28x%29%29+%3D+%0A++++%5CBigl%28%0A++++++++-+%5Cmathrm%7Blog%7D+%5Cbigl%28Q%28x%29+%5Cbigr%29+%0A++++%5CBigr%29+-%0A++++%5CBigl%28+%0A++++++++-+%5Cmathrm%7Blog%7D+%5Cbigl%28P%28x%29+%5Cbigr%29+%0A++++%5CBigr%29+%3D+%5Cmathrm%7Blog%7D+%5Cdfrac%7BP%28x%29%7D%7BQ%28x%29%7D" alt="I(Q(x)) - I(P(x)) =
\Bigl(
- \mathrm{log} \bigl(Q(x) \bigr)
\Bigr) -
\Bigl(
- \mathrm{log} \bigl(P(x) \bigr)
\Bigr) = \mathrm{log} \dfrac{P(x)}{Q(x)}" /></p>
<p>よって</p>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+D_%7BKL%7D%28P%7C%7CQ%29+%3D+%5Csum_%7Bx%7D+P%28x%29+%0A++++%5Cbiggl%28+%0A++++++++%5CBigl%28%0A++++++++++++-+%5Cmathrm%7Blog%7D+%5Cbigl%28+Q%28x%29+%5Cbigr%29+%0A++++++++%5CBigr%29+-+%0A++++++++%5CBigl%28+%0A++++++++++++-+%5Cmathrm%7Blog%7D+%5Cbigl%28+P%28x%29+%5Cbigr%29+%0A++++++++%5CBigr%29+%0A++++%5Cbiggr%29+%0A++++%3D+%5Csum_%7Bx%7D+P%28x%29+%5Cmathrm%7Blog%7D+%5Cdfrac%7BP%28x%29%7D%7BQ%28x%29%7D++" alt="D_{KL}(P||Q) = \sum_{x} P(x)
\biggl(
\Bigl(
- \mathrm{log} \bigl( Q(x) \bigr)
\Bigr) -
\Bigl(
- \mathrm{log} \bigl( P(x) \bigr)
\Bigr)
\biggr)
= \sum_{x} P(x) \mathrm{log} \dfrac{P(x)}{Q(x)} " /></p>
<h4 id="交差エントロピー"><a href="#%E4%BA%A4%E5%B7%AE%E3%82%A8%E3%83%B3%E3%83%88%E3%83%AD%E3%83%94%E3%83%BC">交差エントロピー</a></h4>
<p>KLダイバージェンスの一部を取り出したもの<br />
<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+Q" alt="Q" />(想定していた信号)についての自己情報量を<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+P" alt="P" />(現実の信号)の分布で平均<br />
エントロピーは<img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+H" alt="H" />で表す</p>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+D_%7BKL%7D%28P%7C%7CQ%29+%3D+%5Csum_%7Bx%7D+%0A++++%5Coverbrace%7B+P%28x%29+%7D%5E%7B%281%29%2C+%282%29%7D+%0A++++%5Cbiggl%28+%0A++++++++%5CBigl%28%0A++++++++++++%5Coverbrace%7B%0A++++++++++++++++-+%5Cmathrm%7Blog%7D+%5Cbigl%28+Q%28x%29+%5Cbigr%29+%0A++++++++++++%7D%5E%7B%281%29%7D%0A++++++++%5CBigr%29+-+%0A++++++++%5CBigl%28+%0A++++++++++++%5Coverbrace%7B%0A++++++++++++++++-+%5Cmathrm%7Blog%7D+%5Cbigl%28+P%28x%29+%5Cbigr%29+%0A++++++++++++%7D%5E%7B%282%29%7D%0A++++++++%5CBigr%29+%0A++++%5Cbiggr%29+" alt="D_{KL}(P||Q) = \sum_{x}
\overbrace{ P(x) }^{(1), (2)}
\biggl(
\Bigl(
\overbrace{
- \mathrm{log} \bigl( Q(x) \bigr)
}^{(1)}
\Bigr) -
\Bigl(
\overbrace{
- \mathrm{log} \bigl( P(x) \bigr)
}^{(2)}
\Bigr)
\biggr) " /></p>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Coverbrace%7B%0A++++++++H%28P%2C+Q%29%0A+++++%7D%5E%7Bfrom+%281%29%7D+%3D+%0A+++++%5Coverbrace%7B%0A+++++++++H%28P%29%0A++++++%7D%5E%7Bfrom+%282%29%7D+%0A++++++%2B+D_%7BKL%7D%28P%7C%7CQ%29" alt="\overbrace{
H(P, Q)
}^{from (1)} =
\overbrace{
H(P)
}^{from (2)}
+ D_{KL}(P||Q)" /></p>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+H%28P%2C+Q%29+%0A++++%3D+-+%5Cmathbb%7BE%7D_%7Bx+%5Csim+P%7D+%5Cmathrm%7Blog%7D+Q%28x%29+%0A%3D+%5Csum_%7Bx%7D+P%28x%29+%5Cmathrm%7Blog%7D+Q%28x%29" alt="H(P, Q)
= - \mathbb{E}_{x \sim P} \mathrm{log} Q(x)
= \sum_{x} P(x) \mathrm{log} Q(x)" /></p>
marshmallow444
tag:crieit.net,2005:PublicArticle/17611
2021-08-21T19:16:44+09:00
2021-10-12T12:44:36+09:00
https://crieit.net/posts/Docker-Kaggle
Dockerを使ってKaggleの環境を構築する
<p>10/12追記:<br />
VSCodeを使いたい場合は「<a href="https://crieit.net/posts/Docker-VSCode-Kaggle">ローカルでDocker+VSCodeを使ったKaggleの環境構築メモ</a>」の方法がおすすめ。<br />
本記事の方法は、上記記事より手軽に試したい場合におすすめ。</p>
<hr />
<p>「<a target="_blank" rel="nofollow noopener" href="https://qiita.com/bam6o0/items/354faa9394755a984661">爆速でKaggle環境を構築する</a>」の手順に従って、Docker初心者がmac OS上にKaggleのNotebookの実行環境を構築してみたメモ。</p>
<h2 id="環境構築手順"><a href="#%E7%92%B0%E5%A2%83%E6%A7%8B%E7%AF%89%E6%89%8B%E9%A0%86">環境構築手順</a></h2>
<ol>
<li>Dockerをインストールする</li>
<li>terminalにて、以下のコマンドを実行する<br />
<code>$ docker run --rm -it kaggle/python</code><br />
→これにより、Kaggle Python docker imageがPullされる</li>
</ol>
<h4 id="つまづいたところ"><a href="#%E3%81%A4%E3%81%BE%E3%81%A5%E3%81%84%E3%81%9F%E3%81%A8%E3%81%93%E3%82%8D">つまづいたところ</a></h4>
<ul>
<li>コマンド実行時に、以下のようなエラーが出て失敗した<br />
<code>Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?</code><br />
Dockerを起動してから実行することで、うまくいった<br />
<code>open /Applications/Docker.app</code></li>
</ul>
<h2 id="Notebookの実行方法"><a href="#Notebook%E3%81%AE%E5%AE%9F%E8%A1%8C%E6%96%B9%E6%B3%95">Notebookの実行方法</a></h2>
<ol>
<li>以下のコマンドを実行する<br />
<code>docker run -v $PWD:/tmp/working -w=/tmp/working -p 8888:8888 --rm -it kaggle/python jupyter notebook --no-browser --ip="0.0.0.0" --notebook-dir=/tmp/working --allow-root</code></li>
<li>いくつかURLが出力されるので、ブラウザでそのいずれかのURLへアクセスする</li>
<li><code>.ipynb</code>ファイルを開くと編集・実行できる</li>
</ol>
<h4 id="1.のコマンドを短くする方法"><a href="#1.%E3%81%AE%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%82%92%E7%9F%AD%E3%81%8F%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95">1.のコマンドを短くする方法</a></h4>
<p><code>.bash_profile</code>へ、以下を追記する</p>
<pre><code>kaggle_jupyter() {
docker run -v $PWD:/tmp/working -w=/tmp/working -p 8888:8888 --rm -it kaggle/python jupyter notebook --no-browser --ip="0.0.0.0" --notebook-dir=/tmp/working --allow-root
}
</code></pre>
<p>これにより、terminalで以下を実行するだけでよくなる</p>
<pre><code>$ kaggle_jupyter
</code></pre>
<h2 id="メモ"><a href="#%E3%83%A1%E3%83%A2">メモ</a></h2>
<ul>
<li>実行にかかった時間は、<a href="https://crieit.net/posts/Kaggle-Notebook">Dockerを使わずVSCodeで実行した時</a>に比べると1.25倍ほどかかった。それでもKaggleのKernel上で実行するより早い</li>
<li>いちいちローカルにライブラリをインストールする必要がないので、一度この方法で環境構築しておくと後が楽になりそう</li>
<li>コマンド内の<code>--rm</code>の意味:クリーンアップ
<ul>
<li>コンテナの終了時に、自動的にコンテナをクリーンアップし、ファイルシステムを削除する</li>
</ul></li>
<li>コマンド内の<code>-it</code>の意味:オプション<code>-i</code>と<code>-t</code>の指定
<ul>
<li><code>-i</code>(=<code>--interactive</code>):標準入力</li>
<li><code>-t</code>(=<code>--tty</code>):擬似端末</li>
</ul></li>
<li>Dockerのコンテナの中にログインするには、以下のコマンドを実行する<br />
<code>docker run -it (コンテナ名) bash</code></li>
<li>この方法はかなり多くの容量を要するので、クラウド上にこの環境を構築する手もある。もしmacの容量が足りなくなったら試してみるのもいいかも</li>
</ul>
<h2 id="参考"><a href="#%E5%8F%82%E8%80%83">参考</a></h2>
<ul>
<li><a target="_blank" rel="nofollow noopener" href="https://qiita.com/bam6o0/items/354faa9394755a984661">爆速でKaggle環境を構築する</a></li>
<li><a target="_blank" rel="nofollow noopener" href="https://docs.docker.jp/engine/reference/run.html#clean-up-rm">Docker run リファレンス</a></li>
<li><a target="_blank" rel="nofollow noopener" href="https://qiita.com/k_uchida_____/items/8ca31226bd6d10850791">docker run -it の「-it」とはなにか</a></li>
<li><a target="_blank" rel="nofollow noopener" href="https://www.task-notes.com/entry/20191013/1570961482">MacでDockerのインストールとチュートリアルまで</a></li>
<li><a target="_blank" rel="nofollow noopener" href="https://scitaku.hatenablog.com/entry/2019/06/09/005657">kaggleやろおぜ(環境構築編)</a></li>
</ul>
marshmallow444
tag:crieit.net,2005:PublicArticle/17610
2021-08-19T19:34:46+09:00
2021-08-19T19:34:46+09:00
https://crieit.net/posts/Kaggle-Notebook
KaggleのNotebookをローカルで編集する
<p>KaggleのKernel上でコードを動かしてみたら実行に時間がかかったので、ローカルで実行してみた。<br />
手順を忘れないようメモしておく。<br />
一旦ソースをダウンロードしてローカルで編集し、完成したらアップロードしてSave&Submitする、という流れ。</p>
<h2 id="環境構築"><a href="#%E7%92%B0%E5%A2%83%E6%A7%8B%E7%AF%89">環境構築</a></h2>
<p>mac OS(10.15.7) + VSCodeを使用している</p>
<ul>
<li><a target="_blank" rel="nofollow noopener" href="https://azure.microsoft.com/ja-jp/products/visual-studio-code/">VSCode</a>と<a target="_blank" rel="nofollow noopener" href="https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter">jupyterのExtension</a>をインストールしておく</li>
<li>必要なライブラリをインストールしておく<br />
(参考:<a target="_blank" rel="nofollow noopener" href="https://qiita.com/m__k/items/5f905cf5d20e875961b5">LightGBMをインストール</a>)</li>
</ul>
<h2 id="ローカルでの実行手順"><a href="#%E3%83%AD%E3%83%BC%E3%82%AB%E3%83%AB%E3%81%A7%E3%81%AE%E5%AE%9F%E8%A1%8C%E6%89%8B%E9%A0%86">ローカルでの実行手順</a></h2>
<ul>
<li>Kaggleから、編集したいNotebookをダウンロードする
<ul>
<li>Notebookの左上<code>File</code>メニュー→<code>Download notebook</code>を選択</li>
</ul></li>
<li>(Competitionページの<code>Data</code>タブから、必要なデータもダウンロードしておく)</li>
<li>ダウンロードした<code>.ipynb</code>ファイルをVSCodeで開き、編集・実行する</li>
</ul>
<h2 id="ソースのアップロード手順"><a href="#%E3%82%BD%E3%83%BC%E3%82%B9%E3%81%AE%E3%82%A2%E3%83%83%E3%83%97%E3%83%AD%E3%83%BC%E3%83%89%E6%89%8B%E9%A0%86">ソースのアップロード手順</a></h2>
<ul>
<li>新規Notebookを作成する
<ul>
<li>既存のNotebookへ上書きする場合は、そのNotebookを開く</li>
</ul></li>
<li>左上<code>File</code>メニュー→<code>Upload Notebook</code>を選択
<ul>
<li>Uploadすると、Notebookの内容は全て上書きされてしまうので要注意</li>
</ul></li>
</ul>
<p>アップロード後は、通常通りSaveとSubmitを行う。</p>
<h2 id="備考"><a href="#%E5%82%99%E8%80%83">備考</a></h2>
<ul>
<li><a target="_blank" rel="nofollow noopener" href="https://www.currypurin.com/entry/2019/06/10/120225">ローカルのjupyterかkaggleのKernelかを判定する方法</a>を使うと、環境によって処理を変えられる</li>
<li>ローカルで動かすのにかかった時間は、Kaggle Kernel上で動かした時の半分程度になった
<ul>
<li>まだ一つのソースしか動かしていないので、他のソースでも同様の速度になるのかは不明</li>
</ul></li>
</ul>
marshmallow444
tag:crieit.net,2005:PublicArticle/17581
2021-08-09T19:29:26+09:00
2021-08-09T19:31:41+09:00
https://crieit.net/posts/DeepLearning-Google-Colab-3
【ゼロから作るDeepLearning】Google Colabでコードを動かす(3章)
<p>「ゼロから作るDeepLearning」のサンプルコードをGoogle Colaboratoryで動かしてみている。<br />
3章でうまく動かなかったところをメモしておく。</p>
<h3 id="3.6.1 MNISTデータセット"><a href="#3.6.1+MNIST%E3%83%87%E3%83%BC%E3%82%BF%E3%82%BB%E3%83%83%E3%83%88">3.6.1 MNISTデータセット</a></h3>
<h4 id="p.73"><a href="#p.73">p.73</a></h4>
<p>【問題点】<br />
MNISTデータのダウンロードが出来ない</p>
<p>【原因】<br />
データのあるサーバからエラーが返されているらしい <sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup></p>
<p>【対策】<br />
データをダウンロードする代わりに、keras等からMNISTデータを取得する <sup id="fnref:2"><a href="#fn:2" class="footnote-ref" role="doc-noteref">2</a></sup></p>
<pre><code>from keras.datasets import mnist
(x_train, t_train), (x_test, t_test) = mnist.load_data()
# それぞれのデータの形状を出力
print(x_train.shape)
print(t_train.shape)
print(x_test.shape)
print(t_test.shape)
</code></pre>
<p>【備考】</p>
<ul>
<li>Google Drive上の別ファイルをインポートするには、Google Driveをマウントする必要がある</li>
</ul>
<pre><code>from google.colab import drive
drive.mount('/content/drive', force_remount=True)
</code></pre>
<p>上記コードを実行後、ブラウザ上で認証手続きを行うとマウントできる<br />
インポートは以下の要領で行う</p>
<pre><code>import sys
sys.path.append('/content/drive/My Drive/ColabNotebooks/path/to/dataset/')
from mnist import load_mnist
</code></pre>
<ul>
<li><code>x_train</code>や<code>x_test</code>のサイズに注意
<ul>
<li>サンプルコードでは768個の要素からなる1次元配列として取得されるが、kerasで取得したデータは28*28の2次元配列のまま取得される</li>
</ul></li>
</ul>
<h4 id="p.74〜75"><a href="#p.74%E3%80%9C75">p.74〜75</a></h4>
<p>【問題点】<br />
MNIST画像の表示ができない</p>
<p>【原因】<br />
Google Colaboratory上だと<code>PIL</code>の<code>Image</code>の<code>show()</code>がうまく動かない</p>
<p>【対策】<br />
代わりに<code>IPython.display()</code>を使う <sup id="fnref:3"><a href="#fn:3" class="footnote-ref" role="doc-noteref">3</a></sup></p>
<pre><code>from PIL import Image
from IPython.display import display
def img_show(img):
pil_img = Image.fromarray(np.uint8(img))
display(pil_img)
</code></pre>
<h3 id="3.6.2 ニューラルネットワークの推論処理"><a href="#3.6.2+%E3%83%8B%E3%83%A5%E3%83%BC%E3%83%A9%E3%83%AB%E3%83%8D%E3%83%83%E3%83%88%E3%83%AF%E3%83%BC%E3%82%AF%E3%81%AE%E6%8E%A8%E8%AB%96%E5%87%A6%E7%90%86">3.6.2 ニューラルネットワークの推論処理</a></h3>
<h4 id="p.76〜77"><a href="#p.76%E3%80%9C77">p.76〜77</a></h4>
<p>【問題点】<br />
MNISTのデータをkerasから取得したが、データのshapeがサンプルコードと違う</p>
<p>【対策】<br />
以下の要領で変換したデータを使う</p>
<pre><code>reshaped_data = x_test.reshape(10000, 784)
</code></pre>
<p>【備考】<br />
サンプルコードでは画像データを正規化しているので、同様の処理をすると本に書かれている通りのAccuracyが出る</p>
<pre><code>normalized_data = x_test.reshape(10000, 784) / 255.0
</code></pre>
<div class="footnotes" role="doc-endnotes">
<hr />
<ol>
<li id="fn:1" role="doc-endnote">
<p><a target="_blank" rel="nofollow noopener" href="https://stackoverflow.com/questions/66577151/http-error-when-trying-to-download-mnist-data">https://stackoverflow.com/questions/66577151/http-error-when-trying-to-download-mnist-data</a> <a href="#fnref:1" class="footnote-backref" role="doc-backlink">↩︎</a></p>
</li>
<li id="fn:2" role="doc-endnote">
<p><a target="_blank" rel="nofollow noopener" href="https://colab.research.google.com/drive/1xckYBNOaRYojHrJVy6-D8O57bcjW8v4P#scrollTo=jnMMc6ivvI_a">https://colab.research.google.com/drive/1xckYBNOaRYojHrJVy6-D8O57bcjW8v4P#scrollTo=jnMMc6ivvI_a</a> <a href="#fnref:2" class="footnote-backref" role="doc-backlink">↩︎</a></p>
</li>
<li id="fn:3" role="doc-endnote">
<p><a target="_blank" rel="nofollow noopener" href="https://qiita.com/kaityo256/items/ce34f412ceec1b72755d">https://qiita.com/kaityo256/items/ce34f412ceec1b72755d</a> <a href="#fnref:3" class="footnote-backref" role="doc-backlink">↩︎</a></p>
</li>
</ol>
</div>
marshmallow444
tag:crieit.net,2005:PublicArticle/17550
2021-07-31T18:38:27+09:00
2021-07-31T18:39:18+09:00
https://crieit.net/posts/Google-Colab-61051a1338edc
Google Colabで画像ファイルを書き出す
<p>Google ColaboratoryにてGoogle Drive上に画像を書き出してみたくなったので、そのやり方を調べてみた。<br />
なお ここで書き出す画像データは、kerasから取得したMNISTデータを使用している。</p>
<h2 id="画像ファイルを書き出す方法"><a href="#%E7%94%BB%E5%83%8F%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%82%92%E6%9B%B8%E3%81%8D%E5%87%BA%E3%81%99%E6%96%B9%E6%B3%95">画像ファイルを書き出す方法</a></h2>
<ol>
<li><p>ドライブのマウントを行う</p>
<pre><code>from google.colab import auth
auth.authenticate_user()
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from oauth2client.client import GoogleCredentials
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)
</code></pre></li>
<li><p>画像保存処理を行う関数を定義する</p>
<pre><code>from PIL import Image
import IPython
import sys
import os
file_name = 'test.jpg'
dir_name = '/content/drive/My Drive/Colab Notebooks/path/to/the/folder/' # ←適宜書き換える
sys.path.append(dir_name)
os.chdir(dir_name) # ディレクトリを移動
def img_save(img):
pil_img = Image.fromarray(np.uint8(img))
pil_img.save(file_name)
# UPLOADする
f = drive.CreateFile({'title': file_name, 'mimeType': 'image/png'})
# f.SetContentFile(file_name) # ←実行するとエラーに。なくても書き出せた
f.Upload()
</code></pre></li>
<li><p>上記関数を使って画像を書き出す</p>
<pre><code>from keras.datasets import mnist
(x_train, t_train), (x_test, t_test) = mnist.load_data()
img = x_train[0]
label = t_train[0]
img_save(img)
</code></pre></li>
</ol>
<h2 id="参考"><a href="#%E5%8F%82%E8%80%83">参考</a></h2>
<ul>
<li><a target="_blank" rel="nofollow noopener" href="https://qiita.com/plumfield56/items/c960d36f9224a68a4405">Python(Colab)でウェブ上の画像をドライブに保存する</a></li>
<li><a target="_blank" rel="nofollow noopener" href="https://skattun.hatenablog.jp/entry/2019/04/30/233526">google colab で google driveを使う</a></li>
<li><a target="_blank" rel="nofollow noopener" href="https://teratail.com/questions/224318">Google Colaboratory でFileNotFoundErrorが出る。</a></li>
</ul>
marshmallow444
tag:crieit.net,2005:PublicArticle/17549
2021-07-31T18:37:02+09:00
2021-07-31T18:37:02+09:00
https://crieit.net/posts/Google-Colab
(随時追記)Google Colabで役立つショートカット
<p>最近<a target="_blank" rel="nofollow noopener" href="https://www.oreilly.co.jp/books/9784873117584/">ゼロつく</a>のコードをGoogle Colaboratory上で動かしているが、<br />
その際に便利だなと思ったGoogle Colaboratoryのショートカットをメモしておく。</p>
<ul>
<li><code>Command + M → B</code>
<ul>
<li>コードセルを挿入する</li>
</ul></li>
<li><code>Command + Enter</code>
<ul>
<li>選択中のコードセルを実行する</li>
</ul></li>
<li><code>Ctrl^ + Command + F9</code>
<ul>
<li>最初から全てのコードセルを順に実行する</li>
</ul></li>
<li><code>Ctrl^ + Command + F10</code>
<ul>
<li>選択中のもの以降のコードセルを全て実行する</li>
</ul></li>
</ul>
<p>新たに見つけたものがあれば、随時追記していく予定。</p>
marshmallow444
tag:crieit.net,2005:PublicArticle/17545
2021-07-29T17:26:06+09:00
2021-07-29T17:26:06+09:00
https://crieit.net/posts/GitHub-Pages
GitHub Pagesで数式を表示する
<p><a target="_blank" rel="nofollow noopener" href="https://marshmallow444.github.io/tech_blog/">GitHub Pagesで作ったブログ</a>にて数式を表示したくなったので、TeXを使った方法を調べてみた。<br />
なお、そのブログではJekyllを使い、Markdownで記述している。(ブログ作成時の記事は<a target="_blank" rel="nofollow noopener" href="https://marshmallow444.github.io/tech_blog/2020/09/28/start-a-blog-with-github-pages.html">こちら</a>)</p>
<h2 id="方法1"><a href="#%E6%96%B9%E6%B3%951">方法1</a></h2>
<p>以下のスクリプトをMarkdownファイル内に記述しておく。(MathJaxが読み込まれる)</p>
<pre><code><script type="text/x-mathjax-config">MathJax.Hub.Config({tex2jax:{inlineMath:[['\$','\$'],['\\(','\\)']],processEscapes:true},CommonHTML: {matchFontHeight:false<span>}</span><span>}</span>);</script>
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML"></script>
</code></pre>
<h4 id="注意事項"><a href="#%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A0%85">注意事項</a></h4>
<ul>
<li>コマンドの頭以外で<code>\</code>を使用する際は、2つ記述する必要がある?</li>
<li>改行時は<code>\\\\</code>(バックスラッシュ4つ + 半角スペース2つ)を入力しないと改行されない</li>
</ul>
<h4 id="参考:"><a href="#%E5%8F%82%E8%80%83%EF%BC%9A">参考:</a></h4>
<ul>
<li><a target="_blank" rel="nofollow noopener" href="https://qiita.com/BurnEtz/items/e79999264125eb128ae7">GitHub Pagesで数式を書く方法と主なトラブルについて</a></li>
</ul>
<h2 id="方法2"><a href="#%E6%96%B9%E6%B3%952">方法2</a></h2>
<p>MathJax の読み込みとオプション設定をまとめてhtmlファイルとして保存しておき、使用するテーマでそれを読み込むようにする (動作未確認)</p>
<h4 id="参考:"><a href="#%E5%8F%82%E8%80%83%EF%BC%9A">参考:</a></h4>
<ul>
<li><a target="_blank" rel="nofollow noopener" href="https://qiita.com/memakura/items/e4d2de379f98ad7be498">Github Pages で数式を ~ MathJax v3 設定のポイント</a></li>
<li><a target="_blank" rel="nofollow noopener" href="https://pandanote.info/?p=3715">GitHub Pagesでちょっと遊んでみる(3): GitHub PagesでMathJax!!</a></li>
</ul>
<h2 id="方法3"><a href="#%E6%96%B9%E6%B3%953">方法3</a></h2>
<p><a target="_blank" rel="nofollow noopener" href="https://tex-image-link-generator.herokuapp.com/">tex image link generator</a>を使う<br />
使い方はこちら→<a target="_blank" rel="nofollow noopener" href="https://aotamasaki.hatenablog.com/entry/2020/08/09/github%E3%82%84note%E3%81%A7%E3%82%82TeX%E3%81%AE%E6%95%B0%E5%BC%8F%E3%82%92%E6%9B%B8%E3%81%8F%E3%81%9C">githubやnoteでもTeXの数式を書くぜ</a></p>
<h4 id="具体例"><a href="#%E5%85%B7%E4%BD%93%E4%BE%8B">具体例</a></h4>
<p>入力するテキスト:</p>
<pre><code>\begin{align*}
\frac{d}{dx} \int_a^x f(t) \: dt = f(x)
\end{align*}
</code></pre>
<p>生成されるテキスト(Markdown用):</p>
<pre><code>![\begin{align*}
\frac{d}{dx} \int_a^x f(t) \: dt = f(x)
\end{align*}
](https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0A%5Cfrac%7Bd%7D%7Bdx%7D+%5Cint_a%5Ex+f%28t%29+%5C%3A+dt+%3D+f%28x%29%0A%5Cend%7Balign%2A%7D%0A)
</code></pre>
<p>上記テキストをMarkdown内に張り付けると、以下のような表示になる。</p>
<p><img src="https://render.githubusercontent.com/render/math?math=%5Cdisplaystyle+%5Cbegin%7Balign%2A%7D%0A%5Cfrac%7Bd%7D%7Bdx%7D+%5Cint_a%5Ex+f%28t%29+%5C%3A+dt+%3D+f%28x%29%0A%5Cend%7Balign%2A%7D%0A" alt="\begin{align*}
\frac{d}{dx} \int_a^x f(t) : dt = f(x)
\end{align*}
" /></p>
<h2 id="備考"><a href="#%E5%82%99%E8%80%83">備考</a></h2>
<p>TeXを初めて使うので、よく分かっていないことがありそう。今後何か気づいたことがあれば追記していく。</p>
marshmallow444
tag:crieit.net,2005:PublicArticle/17543
2021-07-28T18:50:16+09:00
2021-07-28T18:50:16+09:00
https://crieit.net/posts/GitHub-610128580bf39
GitHubのパスワード認証が通らなかった話
<p>約1週間前まではGitHubのパスワード認証が使えていたのに、<br />
今日突然使えなくなっていたのでメモ。</p>
<h2 id="発生した問題"><a href="#%E7%99%BA%E7%94%9F%E3%81%97%E3%81%9F%E5%95%8F%E9%A1%8C">発生した問題</a></h2>
<p>GitHubにソースをpushしようとしたが、エラー(403)が出て失敗した。<br />
以下のようなメッセージが出ていた。</p>
<pre><code>remote: Password authentication is temporarily disabled as part of a brownout. Please use a personal access token instead.
remote: Please see https://github.blog/2020-07-30-token-authentication-requirements-for-api-and-git-operations/ for more information.
</code></pre>
<h2 id="解決方法"><a href="#%E8%A7%A3%E6%B1%BA%E6%96%B9%E6%B3%95">解決方法</a></h2>
<ol>
<li><p><a target="_blank" rel="nofollow noopener" href="https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token">Creating a personal access token</a> に書かれている手順でPersonal Access Tokenを作成する</p></li>
<li><p>Terminalにて、以下のコマンドを実行する:<br />
<code>git config --global --add user.password 取得したトークン</code></p></li>
<li>Keychain AccessにてGitHubの情報を探し、パスワード欄を取得したトークンで置き換える</li>
</ol>
<p>この記事の通りだった↓<br />
<a target="_blank" rel="nofollow noopener" href="https://qiita.com/kanta_yamaoka/items/1a59892028b9c422df22">GitHubの認証方法の新しいビッグウェーブに乗り遅れるな!</a></p>
<h2 id="備考"><a href="#%E5%82%99%E8%80%83">備考</a></h2>
<ul>
<li>トークンの有効期限が切れたら、また上記手順を行う必要がある</li>
<li>約1週間前に、GitHubからこんなメールが届いていた。気付かなかった・・・</li>
</ul>
<pre><code>Hi (ユーザ名),
You recently used a password to access the repository at (リポジトリ名) with git using git/2.0 (libgit2 0.26.0).
Basic authentication using a password to Git is deprecated and will soon no longer work. Visit https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information around suggested workarounds and removal dates.
Thanks,
The GitHub Team
</code></pre>
marshmallow444
tag:crieit.net,2005:PublicArticle/17542
2021-07-28T18:48:05+09:00
2021-07-28T18:53:05+09:00
https://crieit.net/posts/02db5a7a96484384bf836c83d0a020e5
【ラビット・チャレンジ】スタートテストに挑戦してみた
<p><a target="_blank" rel="nofollow noopener" href="https://ai999.careers/rabbit/">ラビット・チャレンジ</a>のスタートテストに挑戦したので、メモを残しておく。</p>
<h2 id="出題内容"><a href="#%E5%87%BA%E9%A1%8C%E5%86%85%E5%AE%B9">出題内容</a></h2>
<p><a target="_blank" rel="nofollow noopener" href="https://kentei.ai/introduction/subjecttrend/syllabus_a">AI実装検定A級</a>相当の内容だったらしい。<br />
(この検定に合格している人は、スタートテストを免除される)</p>
<h4 id="即答できなかった項目"><a href="#%E5%8D%B3%E7%AD%94%E3%81%A7%E3%81%8D%E3%81%AA%E3%81%8B%E3%81%A3%E3%81%9F%E9%A0%85%E7%9B%AE">即答できなかった項目</a></h4>
<div class="table-responsive"><table>
<thead>
<tr>
<th>項目</th>
<th>参考URL</th>
</tr>
</thead>
<tbody>
<tr>
<td>逆行列</td>
<td><a target="_blank" rel="nofollow noopener" href="https://atarimae.biz/archives/23994">https://atarimae.biz/archives/23994</a> <a target="_blank" rel="nofollow noopener" href="https://atarimae.biz/archives/24004">https://atarimae.biz/archives/24004</a></td>
</tr>
<tr>
<td>条件付き確率</td>
<td><a target="_blank" rel="nofollow noopener" href="https://miwotukusi.hatenablog.jp/entry/2016/01/25/195720">https://miwotukusi.hatenablog.jp/entry/2016/01/25/195720</a></td>
</tr>
<tr>
<td>分数関数の極限</td>
<td><a target="_blank" rel="nofollow noopener" href="https://math.nakaken88.com/textbook/basic-limit-of-rational-function/">https://math.nakaken88.com/textbook/basic-limit-of-rational-function/</a></td>
</tr>
<tr>
<td>logの微分</td>
<td><a target="_blank" rel="nofollow noopener" href="https://www.try-it.jp/chapters-7403/sections-7421/lessons-7446/">https://www.try-it.jp/chapters-7403/sections-7421/lessons-7446/</a></td>
</tr>
<tr>
<td>シグモイド関数の微分</td>
<td><a target="_blank" rel="nofollow noopener" href="https://pikesaku.hatenablog.com/entry/2016/09/26/002404">https://pikesaku.hatenablog.com/entry/2016/09/26/002404</a></td>
</tr>
<tr>
<td>Pandas dropna()</td>
<td><a target="_blank" rel="nofollow noopener" href="https://note.nkmk.me/python-pandas-nan-dropna-fillna/">https://note.nkmk.me/python-pandas-nan-dropna-fillna/</a></td>
</tr>
<tr>
<td>Pandas concat()</td>
<td><a target="_blank" rel="nofollow noopener" href="https://deepage.net/features/pandas-concat.html">https://deepage.net/features/pandas-concat.html</a></td>
</tr>
<tr>
<td>Seaborn jointplot()</td>
<td><a target="_blank" rel="nofollow noopener" href="http://seaborn.pydata.org/generated/seaborn.jointplot.html">http://seaborn.pydata.org/generated/seaborn.jointplot.html</a></td>
</tr>
<tr>
<td>scikit-learn クラスタ分析</td>
<td><a target="_blank" rel="nofollow noopener" href="https://pythondatascience.plavox.info/scikit-learn/%E3%82%AF%E3%83%A9%E3%82%B9%E3%82%BF%E5%88%86%E6%9E%90-k-means">https://pythondatascience.plavox.info/scikit-learn/%E3%82%AF%E3%83%A9%E3%82%B9%E3%82%BF%E5%88%86%E6%9E%90-k-means</a></td>
</tr>
<tr>
<td>平均二乗誤差</td>
<td><a target="_blank" rel="nofollow noopener" href="https://www.atmarkit.co.jp/ait/articles/2105/24/news019.html">https://www.atmarkit.co.jp/ait/articles/2105/24/news019.html</a></td>
</tr>
<tr>
<td>アダマール積</td>
<td><a target="_blank" rel="nofollow noopener" href="https://python.atelierkobato.com/hadamard/">https://python.atelierkobato.com/hadamard/</a></td>
</tr>
<tr>
<td>LPノルム</td>
<td><a target="_blank" rel="nofollow noopener" href="https://qiita.com/kenmatsu4/items/cecb466437da33df2870">https://qiita.com/kenmatsu4/items/cecb466437da33df2870</a></td>
</tr>
</tbody>
</table></div>
<h2 id="結果"><a href="#%E7%B5%90%E6%9E%9C">結果</a></h2>
<p>合計5時間くらい(?)かけて、なんとか回答完了。<br />
60問中57問正解で、ギリギリ合格。</p>
<h2 id="感想"><a href="#%E6%84%9F%E6%83%B3">感想</a></h2>
<ul>
<li>60問は多い。解くのに時間がかかる問題もちらほらあった</li>
<li>制限時間がなく、中断もできるのはありがたかった</li>
<li>答え・解説がないので、どこを間違えたのか分からなかった</li>
<li>計算問題が思ったより多めだった</li>
<li>受験前に<a target="_blank" rel="nofollow noopener" href="https://www.oreilly.co.jp/books/9784873117584/">ゼロつく</a>を少し進めておいて良かったかも?ちょっと役に立った</li>
</ul>
marshmallow444
tag:crieit.net,2005:PublicArticle/17524
2021-07-20T13:57:12+09:00
2021-08-02T12:35:35+09:00
https://crieit.net/posts/G-2021-2
G検定 2021 #2 受験してみたメモ (8/2 結果を追記)
<p>7/17(土)にJDLA主催の<a target="_blank" rel="nofollow noopener" href="https://www.jdla.org/certificate/general/">G検定</a>というものを受験してみた。<br />
<del>結果はまだ出ていないが、</del>とりあえず折角なので記録を残しておく。<br />
(8/2 追記:結果が出たので末尾へ追加した)</p>
<h2 id="自分のスペック"><a href="#%E8%87%AA%E5%88%86%E3%81%AE%E3%82%B9%E3%83%9A%E3%83%83%E3%82%AF">自分のスペック</a></h2>
<ul>
<li>大学は一応情報系出身。音声認識にほんのり関係ある研究をしていた</li>
<li>プログラマとして8年ほど勤務経験あり</li>
<li>AI系の業務経験はなし</li>
</ul>
<h2 id="受験を決める前に勉強していたこと"><a href="#%E5%8F%97%E9%A8%93%E3%82%92%E6%B1%BA%E3%82%81%E3%82%8B%E5%89%8D%E3%81%AB%E5%8B%89%E5%BC%B7%E3%81%97%E3%81%A6%E3%81%84%E3%81%9F%E3%81%93%E3%81%A8">受験を決める前に勉強していたこと</a></h2>
<ul>
<li><a target="_blank" rel="nofollow noopener" href="https://gacco.org">gacco</a>のAI・ML・データサイエンス系の講義を受講</li>
<li>Courseraの<a target="_blank" rel="nofollow noopener" href="https://www.coursera.org/learn/machine-learning">Machine Learning</a> (Stanford University, Andrew Ng先生の講義)を受講</li>
</ul>
<h2 id="G検定のために勉強したこと"><a href="#G%E6%A4%9C%E5%AE%9A%E3%81%AE%E3%81%9F%E3%82%81%E3%81%AB%E5%8B%89%E5%BC%B7%E3%81%97%E3%81%9F%E3%81%93%E3%81%A8">G検定のために勉強したこと</a></h2>
<p>2018年に一度勉強を始めたが、約3ヶ月後に業務多忙になり中断してしまった。</p>
<p>【2018年】<br />
公式テキスト(第1版)を6〜7割くらい勉強。</p>
<p>【2021年】<br />
<a target="_blank" rel="nofollow noopener" href="https://zero2one.jp/product/ai-basic-g-training-v2/">人工知能基礎&G検定実践問題集</a> ((株)zero to one)を受講。<br />
キャンペーン中のため、定価50,000円の内容が6,000円で受講できた。<br />
6月頭に勉強開始して、7月頭まではビデオ講座を見ていた。<br />
(サボりすぎてなかなか進まなかった)<br />
講義資料がダウンロード出来ないので、講義内容は自力でメモした。</p>
<p>視聴が全て終わってから、講座の練習問題を一通り半くらい解いた。<br />
練習問題で即答できなかったことは、ネットで納得いくまで調べて<br />
Notion上に自分用チートシートを作成しておいた。<br />
特に技術系の内容については、単に用語を覚えるだけでなく<br />
図解されたサイトなどを見て概要やイメージを軽く把握した。</p>
<h2 id="本番中の進め方"><a href="#%E6%9C%AC%E7%95%AA%E4%B8%AD%E3%81%AE%E9%80%B2%E3%82%81%E6%96%B9">本番中の進め方</a></h2>
<p>すぐにはわからない問題は、どんどん後回しにしていく作戦で解き進めた。</p>
<p>まずは即答できる問題を一通り解答。これに約80〜90分かかった。<br />
次に未回答のままにしてあった問題を解答。約15分かかった。<br />
残った時間で自信のなかった問題を見直しした。</p>
<h2 id="G検定を受験した感想"><a href="#G%E6%A4%9C%E5%AE%9A%E3%82%92%E5%8F%97%E9%A8%93%E3%81%97%E3%81%9F%E6%84%9F%E6%83%B3">G検定を受験した感想</a></h2>
<p>手応えあり。体感で8〜9割は正答できた気がする。<br />
見たことのない問題も少しあったが、思ったより練習問題に似たものが多かった印象。</p>
<h4 id="【準備しておいて良かったこと】"><a href="#%E3%80%90%E6%BA%96%E5%82%99%E3%81%97%E3%81%A6%E3%81%8A%E3%81%84%E3%81%A6%E8%89%AF%E3%81%8B%E3%81%A3%E3%81%9F%E3%81%93%E3%81%A8%E3%80%91">【準備しておいて良かったこと】</a></h4>
<p>Notionで作っておいたチートシートが役に立った<br />
→練習問題と似た苦手な問題が出たときに、すぐ調べられた<br />
→用語と説明を一行にまとめたら、キーワード検索時に検索結果一覧上で内容を確認できて捗った</p>
<h4 id="【準備しなくても良かったこと】"><a href="#%E3%80%90%E6%BA%96%E5%82%99%E3%81%97%E3%81%AA%E3%81%8F%E3%81%A6%E3%82%82%E8%89%AF%E3%81%8B%E3%81%A3%E3%81%9F%E3%81%93%E3%81%A8%E3%80%91">【準備しなくても良かったこと】</a></h4>
<p>事前にQiitaで見つけたチートシート(用語集)は、本番中は意外と使わなかった</p>
<h2 id="受講した講義の感想"><a href="#%E5%8F%97%E8%AC%9B%E3%81%97%E3%81%9F%E8%AC%9B%E7%BE%A9%E3%81%AE%E6%84%9F%E6%83%B3">受講した講義の感想</a></h2>
<ul>
<li>文字のコピペができないのが不便 (本番環境では試験内容をコピペできないので、それに揃えてあるのかも?)</li>
<li>全体を通して誤字が結構あるのが少し気になった</li>
</ul>
<h4 id="【ビデオ講義】"><a href="#%E3%80%90%E3%83%93%E3%83%87%E3%82%AA%E8%AC%9B%E7%BE%A9%E3%80%91">【ビデオ講義】</a></h4>
<ul>
<li>内容は基礎的なこと。公式テキストに近い印象 (ちゃんと見比べてはいないけど)<br />
これだけで試験の内容を網羅しているわけではない
<ul>
<li>講義動画を一通り見てから練習問題を解いたが、即答できた問題は体感4割前後</li>
</ul></li>
<li>ちょっと説明がわかりづらい箇所もあった</li>
<li>ゼロから勉強を始める方には良いかも?個人的にはちょっと微妙だった</li>
</ul>
<h4 id="【問題集】"><a href="#%E3%80%90%E5%95%8F%E9%A1%8C%E9%9B%86%E3%80%91">【問題集】</a></h4>
<ul>
<li>似たような問題が何問も出ることがある。即答できない問題を飛ばしたら次の問題に答えが書いてあった、なんてこともあった</li>
<li>ここに出てくる練習問題をしっかり解けるようにしておけば、合格出来そうな気がする</li>
<li>受講して良かった</li>
</ul>
<h2 id="おまけ"><a href="#%E3%81%8A%E3%81%BE%E3%81%91">おまけ</a></h2>
<ul>
<li>JDLAおすすめの講座は以下にまとめられている<br />
<a target="_blank" rel="nofollow noopener" href="https://www.jdla.org/recommendedbook/study/">【一部無料】学習コンテンツ・イベントのご紹介 [#今こそ学ぼう]</a></li>
</ul>
<h2 id="(8/2 追記)受験結果"><a href="#%288%2F2+%E8%BF%BD%E8%A8%98%29%E5%8F%97%E9%A8%93%E7%B5%90%E6%9E%9C">(8/2 追記)受験結果</a></h2>
<p>先ほど合格通知のメールが届いた。<br />
だいたい予想していた程度の点数は取れていた様子。<br />
受験してから結果が出るまで、長かった・・・<br />
今回から分野別の得点率が通知されているので、そのせいで時間がかかったのかもしれない。</p>
<p><a href="https://crieit.now.sh/upload_images/4fbdbc0f9c3456a290817275197b0803610767c2b8ab0.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/4fbdbc0f9c3456a290817275197b0803610767c2b8ab0.png?mw=700" alt="image" /></a></p>
marshmallow444