Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/hitowomusubu/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340
プログラミングでできる事 | 夢を叶える塾
スポンサーリンク

プログラミングでできる事

ホームページのリニューアルに伴い一部のページは新しいサイトにリダイレクトされます。

 

プログラミングができるようになると、どんなものを作ることができるのかについてです。

基本的になんでもできる

基本的になんでもできるとは言っても、「お金を作り続けるアプリ」なんてものは作れません。
ですが、システムやゲームで見慣れたアプリやソフトウェアと言ったものは、おおよそ作れるようになります。
何ができるかという話はモチベーションに関わる話ですので、もう少しかみ砕いで解説していきたいと思います。

決まりきった動きを作ることができる

パソコン上で決まりきった動きをするものは、その決まった動きのアルゴリズムさえ作ることができれば実現する事ができます。
例えば複雑な計算も式やその計算方法さえわかっていれば、計算結果を得るプログラムを作ることができるます。
データの加工方法さえわかっていれば、加工されたデータを得るプログラムを作ることができます。
システムやゲーム等、決まりきった動きの連続になっていると思います。
プログラムされたものなのでそのような動きになりますし、逆にそういう動きだからプログラムできています。
(正確にはそういう動きになるようにアルゴリズムを作成する訳ですね)

決まっていない動きには弱い

半面、決まっていない動きには弱い部分があります。
決まっていない動きというと「サイコロの目」のようなランダムな要素を思い浮かべるかもしれません。
しかし、プログラムでランダムに数を生成する事ができますので、このようなランダムな要素は特に問題ありません。

問題なのは正解のない動きで、例えば好き嫌いや気分のようなものです。
好き嫌いにロジカルな要素が無くはないですが「何故好きか?」と聞かれて理由のつけがたいものがありますね。
「今日は何食べようかな・・・寿司を食べに行こう」は気分で、その理由は定まっていません。
そういうものはプログラムしにくくなります。
先の様にランダム要素で好き嫌いや行動を振り分ける事はできますが、ランダムな数字の結果が理由になっています。
昨日「中華にしたから今日は和食」というルールが定まっていれば、それはプログラムできます。

画像データの識別とディープラーニング

画像データから動物を認識する、という類のものもプログラムは難しくなります。
ファイル名に犬やネコと書いてあれば、それは決まった動きなので判断する事はできます。
ふつうは画像データに「これは犬です」と書いていないので、その判断基準が決まっていないからです。

人間は動物を見てネコか犬か直ぐに判別できますが、これをアルゴリズムにできるでしょうか?
確かに多少の特徴の差がありますが、それを言い表すのは難しいですよね。
「犬かネコか判別しろ」という命令をプログラム言語に期待する事もできません。
犬と判別しなさいと言われて判別する事の出来るプログラミング言語を私は知りません。
これを解決できるようになったのが昨今のディープラーニングです。

ディープラーニングは膨大な量のネコと犬の画像データから、犬の画像と猫の画像の特徴を学習することができます。
過去にネコと教えてもらった画像データと犬と教えてもらった画像データの、どちらに比較的近い画像データかは数値化され判断する事ができます。
私の感覚ではこのタイプのディープラーニングの話を(かなり適当ですが)2015年頃から耳にするようになりました。
この技術が発達し、自動運転技術などに応用され、目まぐるしい発展を遂げています。

私もディープラーニングを使ったことはあるものの、詳しくその学習のシステムを理解できているわけではありません。
ただ、ディープラーニングのポイントは、犬やネコの判断方法をアルゴリズムで用意しないという点にあります。
学びながら「輪郭の画像データに着目してみよう」だとか、「目っぽい部分の大きさに着目してみよう」とか、勝手に判断方法を試してうまくいく判断方法を学ぶことができます。
ここにアルゴリズムでは解決できない問題を解決する糸口があります。
「画像データから動物を認識する」というプログラムは従来難しかったわけですが、このディープラーニングにより現実的なものとなりました。

人工知能(AI)とは

ディープラーニングの話を出したので、一応人工知能にも触れておきたいと思います。
人工知能と言っても、色々な意味で使われているのが現状だと思います。
人によってはプログラム自体を人工知能だと捉えている人もいます。
アルゴリズムに従って同じことを繰り返す「だけ」のものすべてが人工知能だと私は余り思えませんが。

将棋の人工知能

将棋や囲碁で人工知能とプロ棋士の対戦はしばしば話題になります。
確かに見ていて面白いものです。(これは私の主観でしかありませんが)
この人工知能の解釈は人によって分かれるところだと思います。

やっている事が特に人間らしい事をしていないからです。
人によっては人間の様に判断するものが人工知能だという人がいます。
確かにそのような定義もあるかもしれませんが、現在の多くの方が使う使われ方とは違っているように感じます。

先のネコや犬の画像データの話で特徴を数値化して判断するという話をしました。
この人工知能も同じで、将棋の盤面に点数をつけています。
次に動かす手を決めると盤面に点数をつけて評価することができます。
これを繰り返し、一番評価の高い手を選ぶという事をやっています。
つまり、超超超複雑な人間では持ち時間では到底不可能な計算をひたすら繰り返した結果、点数の良いものを選ぶというアルゴリズムです。
※ちなみにたぶん正しくは違っていて、ただ、それっぽい事をやっているのかと思います。
この評価の点数のつけ方がうまいかどうかで、人工知能の将棋力が変わってきます。

一方でディープラーニングによる学習の結果というものは、人間の目で見ることができません。
学習させた結果、画像データに対してネコと判断したときに、何故ネコと判断しているのか、わからなくなってしまいます。
将棋の盤面をディープラーニングにより学習した結果「その判断方法すらよくわからないけど、なんかこの手は評価値が高い。」という状態になります。
ここにブラックボックス的な要素があり、この「見えない評価値」が人工知能と呼ばれる理由でしょう。
私としては人間らしい事をしているこの考え方の方がしっくりきます。

気分の人工知能

毎日の食事を気分で決めるとき、それを人工知能にディープラーニングで学習させたらどうなるのでしょうか?
なんかそれっぽい規則を見つけ出し、
人工知能:「今日食べたいのは…カレーですね?」
なんてこと言われて本当に当たっていたら、なんか怖いですね。
人工知能:「明日はハンバーグ、あさってはナポリタン、その次は‥‥」
でも、いずれそういう日が来るのかもしれません。

実現するための文

途中から人工知能の方に話がそれてしまいましたがプログラムの話にもどります。
プログラムは基本的に何でもできます。
問題はそのアルゴリズムを作れるかどうかになり、そして基本的にアルゴリズムは作れます。
そのために必要なアルゴリズムの部品となる文(ステートメント)を解説しておきます。
これらを組み合わせて、あらゆる事を実現できるようになります。

計算

まず何と言っても計算です。
パソコンですから計算は得意です。
人間なら何時間もかかる計算も、現在の技術では一瞬です。
アルゴリズムの中で計算は必ずと言っていいほど必要になります。

入出力

プログラムに何かを与える事を入力、プログラムから何か出すことを出力と言います。
入力と出力を合わせて入出力です。

多くのプログラムは何かしら情報を与え、それに対して処理を行っていると思います。
銀行の振込のシステムであれば口座番号や金額を入力しますね。
入力された口座番号や金額をプログラムが覚えて、振込先へ振り込むという処理を行っています。

同じように多くのプログラムは何かしらの計算結果等を表示します。
プログラムが動いた結果黙っていては何もわからないので、何かしらを吐き出させる必要があります。
それが出力です。

なお、出力する方法は様々です。
テキストとして画面に表示させたり、ファイルに書き出したり、画像として表示させたりもできるでしょう。
プログラム言語は「標準出力」と呼ばれる出力先を持っていて、標準出力に出力させるという方法が最も初歩的な出力方法になります。

条件分岐

アルゴリズムの中で、条件分岐が必要な場合があります。
例えば、与えられた数字が偶数かどうか判断し、その答えを表示するプログラムを考えてみます。

  1. 入力された数字が偶数なら2へ、違ったら3へ
  2. 「偶数」と表示して4へ
  3. 「奇数」と表示して4へ
  4. 終り

このように特定のものを判断し、行う命令を変える事ができます。

図で書くとこんなイメージです。
偶数or奇数

ちなみに、このようなアルゴリズムの流れを視覚的にわかりやすく書いたものをフローチャートと言います。

反復

アルゴリズムによっては特定の命令を繰り返し行う場合があります。
例えば、数当てゲームを思い出してください。

  1. 正解を決めなさい
  2. 入力された数字正しければ3へ、大きければ4へ、小さければ5へ
  3. 「セイカイ」と表示して終わり
  4. 「モットチイサイ」と表示して6へ
  5. 「モットオオキイ」と表示して6へ
  6. 入力された数字正しければ7へ、大きければ8へ、小さければ9へ
  7. 「セイカイ」と表示して終わり
  8. 「モットチイサイ」と表示して10へ
  9. 「モットオオキイ」と表示して10へ
  10. ・・・

一つ一つ書くのは煩わしいですね。

  1. 正解を決めなさい
  2. ここから繰り返し
  3. 入力された数字正しければ4へ、大きければ5へ、小さければ6へ
  4. 「セイカイ」と表示して終わり
  5. 「モットチイサイ」と表示して7へ
  6. 「モットオオキイ」と表示して7へ
  7. ここまで繰り返し、2へ

こうして反復して処理を行う事で正解が出るまで何度でも繰り返して処理が行われます。
ただし、永遠に抜け出せなくなる場合がないように注意しなければなりません。
永遠とループしてしまうようなアルゴリズムを作ってしまうと、いつまでもプログラムが終了しません。
プログラムが動作し続け、CPUを占有してしまいPCがフリーズする事もあります。

その他

プログラム言語により様々な処理が用意されています。
あるプログラム言語ではエクセルのセルの情報を書き換える処理もあります。
様々な処理になりますので一口で言い表すことはできません。
まずは前者の、計算、出力、条件分岐、反復について理解いただければ良いと思います。

終りに

「基本的になんでもできる」と大口を叩いていますが、でもその通りです。
その計算方法や出力方法等が分かっていれば(パソコン上で決まりきった動きであれば)、基本的にはなんでも作れてしまいます。
ソフトウェアやアプリの動作を細かく区切っていけば、計算、入出力、条件分岐、反復、これの繰り返しであると気付くことができると思います。
馴染みのあるソフトウェアの動きをよく観察してみてください。
そのアルゴリズムを考えてみる事は、プログラムの習得に役立つはずです。

にほんブログ村 地域生活(街) 東北ブログへ にほんブログ村 地域生活(街) 東北ブログ 米沢情報へ にほんブログ村 教育ブログへ にほんブログ村 教育ブログ 塾教育へ
スポンサーリンク