第1章はじめに
1.2. Key Components1.2 主な構成要素
In our wake word example, we described a dataset consisting of audio snippets and binary labels, and we gave a hand-wavy sense of how we might train a model to approximate a mapping from snippets to classifications. This sort of problem, where we try to predict a designated unknown label based on known inputs given a dataset consisting of examples for which the labels are known, is called supervised learning. This is just one among many kinds of machine learning problems. Before we explore other varieties, we would like to shed more light on some core components that will follow us around, no matter what kind of machine learning problem we tackle:
英語のヒント
起動語の例では、音声の断片と二値のラベルからなるデータセットを説明し、断片から分類への写像を近似するようにモデルをどう訓練すればよいかを、おおまかに示した。ラベルがわかっている事例からなるデータセットが与えられたもとで、既知の入力にもとづいて指定された未知のラベルを予測しようとする、この種の問題を、教師あり学習という。これは機械学習の多くの種類の問題のうちの一つにすぎない。ほかの種類を探る前に、どんな種類の機械学習の問題に取り組むときもついて回る、いくつかの中心的な構成要素にもっと光を当てておきたい。
- The data that we can learn from.
英語のヒント
学習の材料になるデータ。 - A model of how to transform the data.
英語のヒント
データをどう変換するかのモデル。 - An objective function that quantifies how well (or badly) the model is doing.
英語のヒント
モデルがどれほどうまく(あるいはまずく)やっているかを数値で表す目的関数。 - An algorithm to adjust the model’s parameters to optimize the objective function.
英語のヒント
目的関数を最適化するように、モデルのパラメータを調整するアルゴリズム。
1.2.1. Data1.2.1 データ
It might go without saying that you cannot do data science without data. We could lose hundreds of pages pondering what precisely data is, but for now, we will focus on the key properties of the datasets that we will be concerned with. Generally, we are concerned with a collection of examples. In order to work with data usefully, we typically need to come up with a suitable numerical representation. Each example (or data point, data instance, sample) typically consists of a set of attributes called features (sometimes called covariates or inputs), based on which the model must make its predictions. In supervised learning problems, our goal is to predict the value of a special attribute, called the label (or target), that is not part of the model’s input.
英語のヒント
データなしではデータサイエンスはできない、というのは言うまでもないだろう。データとは正確には何なのかを考えるのに何百ページも費やせるが、今は、私たちが関わることになるデータセットの主な性質に焦点を当てる。一般に、私たちが関心をもつのは事例の集まりである。データを役立つように扱うには、普通、適切な数値表現を考え出す必要がある。各事例(またはデータ点、データインスタンス、サンプル)は、普通、特徴量(共変量や入力と呼ばれることもある)という属性の集まりからなり、モデルはそれにもとづいて予測をしなければならない。教師あり学習の問題では、目標は、ラベル(または目標値)と呼ばれる特別な属性の値を予測することである。ラベルはモデルの入力には含まれない。
If we were working with image data, each example might consist of an individual photograph (the features) and a number indicating the category to which the photograph belongs (the label). The photograph would be represented numerically as three grids of numerical values representing the brightness of red, green, and blue light at each pixel location. For example, a pixel color photograph would consist of numerical values.
英語のヒント
画像データを扱っているなら、各事例は、一枚の写真(特徴量)と、その写真が属するカテゴリーを示す数(ラベル)からなるかもしれない。写真は、各画素の位置での赤、緑、青の光の明るさを表す数値の三つの格子として、数値で表される。たとえば、画素のカラー写真は、個の数値からなる。
Alternatively, we might work with electronic health record data and tackle the task of predicting the likelihood that a given patient will survive the next 30 days. Here, our features might consist of a collection of readily available attributes and frequently recorded measurements, including age, vital signs, comorbidities, current medications, and recent procedures. The label available for training would be a binary value indicating whether each patient in the historical data survived within the 30-day window.
英語のヒント
あるいは、電子カルテのデータを扱い、ある患者が今後30日間生存する見込みを予測する課題に取り組むかもしれない。この場合、特徴量は、年齢、バイタルサイン、併存疾患、現在の投薬、最近の処置など、すぐに手に入る属性や頻繁に記録される測定値の集まりからなるだろう。訓練に使えるラベルは、過去のデータの各患者が30日の期間内に生存したかどうかを示す二値の値になる。
In such cases, when every example is characterized by the same number of numerical features, we say that the inputs are fixed-length vectors and we call the (constant) length of the vectors the dimensionality of the data. As you might imagine, fixed-length inputs can be convenient, giving us one less complication to worry about. However, not all data can easily be represented as fixed-length vectors. While we might expect microscope images to come from standard equipment, we cannot expect images mined from the Internet all to have the same resolution or shape. For images, we might consider cropping them to a standard size, but that strategy only gets us so far. We risk losing information in the cropped-out portions. Moreover, text data resists fixed-length representations even more stubbornly. Consider the customer reviews left on e-commerce sites such as Amazon, IMDb, and TripAdvisor. Some are short: “it stinks!”. Others ramble for pages. One major advantage of deep learning over traditional methods is the comparative grace with which modern models can handle varying-length data.
英語のヒント
このように、どの事例も同じ数の数値の特徴量で特徴づけられるとき、入力は固定長のベクトルであるといい、ベクトルの(一定の)長さをデータの次元数という。想像がつくように、固定長の入力は便利で、気にかける面倒が一つ減る。しかし、すべてのデータが固定長のベクトルとして簡単に表せるわけではない。顕微鏡の画像なら標準的な装置から得られると期待できるかもしれないが、インターネットから掘り出した画像がすべて同じ解像度や形をしているとは期待できない。画像なら、標準的な大きさに切り抜くことも考えられるが、その戦略でできることには限りがある。切り落とした部分の情報を失うおそれがある。しかも、文章のデータは、固定長の表現にいっそう頑固に抵抗する。Amazon、IMDb、TripAdvisorのような電子商取引のサイトに残された客のレビューを考えてみよう。短いものもある。「最悪!」。何ページもとりとめなく続くものもある。従来の手法に比べた深層学習の大きな利点の一つは、現代のモデルが長さの異なるデータを比較的うまく扱えることである。
Generally, the more data we have, the easier our job becomes. When we have more data, we can train more powerful models and rely less heavily on preconceived assumptions. The regime change from (comparatively) small to big data is a major contributor to the success of modern deep learning. To drive the point home, many of the most exciting models in deep learning do not work without large datasets. Some others might work in the small data regime, but are no better than traditional approaches.
英語のヒント
一般に、データが多いほど私たちの仕事は楽になる。データが多ければ、より強力なモデルを訓練でき、前もって抱いた仮定にそれほど頼らずにすむ。(比較的)小さいデータから大きいデータへの体制の変化は、現代の深層学習の成功の大きな要因である。要点をはっきりさせると、深層学習で最も刺激的なモデルの多くは、大きなデータセットなしでは機能しない。ほかのモデルには小さいデータの体制でも機能するものがあるが、従来の手法よりよいわけではない。
Finally, it is not enough to have lots of data and to process it cleverly. We need the right data. If the data is full of mistakes, or if the chosen features are not predictive of the target quantity of interest, learning is going to fail. The situation is captured well by the cliché: garbage in, garbage out. Moreover, poor predictive performance is not the only potential consequence. In sensitive applications of machine learning, like predictive policing, resume screening, and risk models used for lending, we must be especially alert to the consequences of garbage data. One commonly occurring failure mode concerns datasets where some groups of people are unrepresented in the training data. Imagine applying a skin cancer recognition system that had never seen black skin before. Failure can also occur when the data does not only under-represent some groups but reflects societal prejudices. For example, if past hiring decisions are used to train a predictive model that will be used to screen resumes then machine learning models could inadvertently capture and automate historical injustices. Note that this can all happen without the data scientist actively conspiring, or even being aware.
英語のヒント
最後に、データがたくさんあって、それを巧みに処理するだけでは十分ではない。正しいデータが必要である。データが誤りだらけだったり、選んだ特徴量が関心のある目標の量を予測する力をもたなかったりすれば、学習は失敗する。この状況は「ごみを入れればごみが出る(garbage in, garbage out)」という決まり文句がうまく言い表している。しかも、予測性能が低いことだけが起こりうる結果ではない。予測型の警察活動、履歴書の選別、融資に使われるリスクモデルのような、機械学習の繊細な応用では、ごみのデータがもたらす結果にとりわけ警戒しなければならない。よくある失敗の一つは、ある集団の人々が訓練データに含まれていないデータセットにかかわるものである。黒い肌を一度も見たことのない皮膚がんの認識システムを使う場面を想像してほしい。失敗は、データがある集団を少なくしか含まないだけでなく、社会の偏見を反映している場合にも起こりうる。たとえば、過去の採用の決定を使って、履歴書の選別に使う予測モデルを訓練すれば、機械学習モデルは過去の不正義をうっかり取り込み、自動化してしまうかもしれない。これはすべて、データサイエンティストが積極的に企んでいなくても、それどころか気づいてさえいなくても起こりうることに注意してほしい。
1.2.2. Models1.2.2 モデル
Most machine learning involves transforming the data in some sense. We might want to build a system that ingests photos and predicts smiley-ness. Alternatively, we might want to ingest a set of sensor readings and predict how normal vs. anomalous the readings are. By model, we denote the computational machinery for ingesting data of one type, and spitting out predictions of a possibly different type. In particular, we are interested in statistical models that can be estimated from data. While simple models are perfectly capable of addressing appropriately simple problems, the problems that we focus on in this book stretch the limits of classical methods. Deep learning is differentiated from classical approaches principally by the set of powerful models that it focuses on. These models consist of many successive transformations of the data that are chained together top to bottom, thus the name deep learning. On our way to discussing deep models, we will also discuss some more traditional methods.
英語のヒント
ほとんどの機械学習は、何らかの意味でデータを変換することを含む。写真を取り込んで笑顔らしさを予測するシステムを作りたいかもしれない。あるいは、センサーの読み取り値の集まりを取り込み、その値がどれほど正常か異常かを予測したいかもしれない。モデルという言葉で、ある型のデータを取り込み、場合によっては別の型の予測を吐き出す計算の仕組みを指す。特に関心があるのは、データから推定できる統計モデルである。単純なモデルでも、相応に単純な問題には十分に対処できるが、この本で焦点を当てる問題は、古典的な手法の限界を押し広げるものである。深層学習が古典的な手法と区別されるのは、主に、それが焦点を当てる強力なモデルの集まりによってである。これらのモデルは、上から下へとつながれた、データの多くの連続した変換からなる。それゆえに深層学習という名がある。深いモデルを論じる道すがら、もっと伝統的な手法もいくつか論じる。
1.2.3. Objective Functions1.2.3 目的関数
Earlier, we introduced machine learning as learning from experience. By learning here, we mean improving at some task over time. But who is to say what constitutes an improvement? You might imagine that we could propose updating our model, and some people might disagree on whether our proposal constituted an improvement or not.
英語のヒント
先に、機械学習を、経験から学ぶことだと紹介した。ここで学ぶとは、ある課題で時とともに上達することを意味する。しかし、何が上達にあたるのかを誰が決めるのか。モデルの更新を提案しても、その提案が改善になっているかどうかについて意見が分かれる人がいるかもしれない。
In order to develop a formal mathematical system of learning machines, we need to have formal measures of how good (or bad) our models are. In machine learning, and optimization more generally, we call these objective functions. By convention, we usually define objective functions so that lower is better. This is merely a convention. You can take any function for which higher is better, and turn it into a new function that is qualitatively identical but for which lower is better by flipping the sign. Because we choose lower to be better, these functions are sometimes called loss functions.
英語のヒント
学習する機械の形式的な数学の体系を作るには、モデルがどれほどよいか(あるいは悪いか)の形式的な尺度が必要である。機械学習で、より一般には最適化で、これを目的関数と呼ぶ。慣例として、目的関数は普通、低いほどよいように定義する。これは単なる慣例である。高いほどよい関数があれば、符号を反転させるだけで、質的には同じだが低いほどよい新しい関数に変えられる。低いほうをよいとするので、これらの関数は損失関数と呼ばれることもある。
When trying to predict numerical values, the most common loss function is squared error, i.e., the square of the difference between the prediction and the ground truth target. For classification, the most common objective is to minimize error rate, i.e., the fraction of examples on which our predictions disagree with the ground truth. Some objectives (e.g., squared error) are easy to optimize, while others (e.g., error rate) are difficult to optimize directly, owing to non-differentiability or other complications. In these cases, it is common instead to optimize a surrogate objective.
英語のヒント
数値を予測しようとするとき、最もよく使われる損失関数は二乗誤差、つまり予測と正解の目標値との差の二乗である。分類では、最もよくある目的は誤り率、つまり予測が正解と食い違う事例の割合を最小にすることである。目的のなかには(たとえば二乗誤差のように)最適化しやすいものもあれば、(たとえば誤り率のように)微分できないことやほかの面倒のせいで直接最適化しにくいものもある。そうした場合は、代わりに代理の目的を最適化するのが普通である。
During optimization, we think of the loss as a function of the model’s parameters, and treat the training dataset as a constant. We learn the best values of our model’s parameters by minimizing the loss incurred on a set consisting of some number of examples collected for training. However, doing well on the training data does not guarantee that we will do well on unseen data. So we will typically want to split the available data into two partitions: the training dataset (or training set), for learning model parameters; and the test dataset (or test set), which is held out for evaluation. At the end of the day, we typically report how our models perform on both partitions. You could think of training performance as analogous to the scores that a student achieves on the practice exams used to prepare for some real final exam. Even if the results are encouraging, that does not guarantee success on the final exam. Over the course of studying, the student might begin to memorize the practice questions, appearing to master the topic but faltering when faced with previously unseen questions on the actual final exam. When a model performs well on the training set but fails to generalize to unseen data, we say that it is overfitting to the training data.
英語のヒント
最適化のあいだ、損失はモデルのパラメータの関数として考え、訓練データセットは定数として扱う。訓練のために集めたいくつかの事例からなる集合で生じる損失を最小にすることで、モデルのパラメータの最良の値を学ぶ。しかし、訓練データでうまくいっても、未知のデータでうまくいくとは限らない。そこで普通は、使えるデータを二つに分ける。モデルのパラメータを学ぶための訓練データセット(訓練集合)と、評価のためにとっておくテストデータセット(テスト集合)である。最終的には、普通、両方でモデルがどう振る舞うかを報告する。訓練での性能は、本番の期末試験に備えるための練習問題で学生がとる点数のようなものだと考えるとよい。結果が励みになるものであっても、期末試験での成功が保証されるわけではない。勉強するうちに、学生は練習問題を暗記し始め、その話題を身につけたように見えても、実際の期末試験で初めて見る問題に直面するとつまずくかもしれない。モデルが訓練集合ではうまくいくのに未知のデータに汎化できないとき、そのモデルは訓練データに過学習しているという。
1.2.4. Optimization Algorithms1.2.4 最適化アルゴリズム
Once we have got some data source and representation, a model, and a well-defined objective function, we need an algorithm capable of searching for the best possible parameters for minimizing the loss function. Popular optimization algorithms for deep learning are based on an approach called gradient descent. In brief, at each step, this method checks to see, for each parameter, how that training set loss would change if you perturbed that parameter by just a small amount. It would then update the parameter in the direction that lowers the loss.
英語のヒント
データの源と表現、モデル、そしてきちんと定義された目的関数がそろったら、損失関数を最小にする、可能なかぎり最良のパラメータを探せるアルゴリズムが必要になる。深層学習でよく使われる最適化アルゴリズムは、勾配降下法と呼ばれる手法にもとづいている。手短に言えば、この手法は各ステップで、パラメータの一つひとつについて、そのパラメータをほんの少しだけ動かしたら訓練集合の損失がどう変わるかを調べる。そして、損失を下げる方向にパラメータを更新するのである。