TensorFlow Developer証明書準備プロセス&後期1
TensorFlow Developer certificate準備用のコセラ川!
4つの授業があるのかと思ったらそうではありませんでした^^..
このコースには4つの講座(各講座には私の多くの講座があります^.)
Introduction to TensorFlow for Artificial Intelligence, Machine Learning, and Deep Learning
Natural Language Processing in TensorFlow
Sequences, Time Series and Prediction
Convolutional Neural Networks in TensorFlow
それぞれ聴講し、内容(概要)を整理し、試験後に後期まで書きます!
(これは4つの授業で構成されています)
既存のプログラミングがルールとデータを入力して結果値を取得している場合.
機械学習は,結果値とデータを入力して繰返しモードを検索し,ルールを導出するプロセスである.
第1の説明では、hellow worldレベルの簡単な例じっけんたんニューロン
用語
dense : A layer of connected neurons
Optimizer : Figures out how to efficiently compile your code
Loss : Measures how good the current ‘guess’ is_
xs = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype=float)
ys = np.array([1.0, 1.5, 2.0, 2.5, 3.0, 3.5], dtype=float)
house modelという関数を作成して、上記の2つの数の間の(xとy)関係を導出し、1000回(epochs=1000)7.0を訓練し、xが与えられたときにyを導出する.
上は4のはずですが、4に近い値しかありません.
(フォックスが1つ上がるたびにロスは徐々に低下します)
Fashion MNISTという名前のデータセットを構築し、AIを学習することで、画像の服のタイプを認識できます。(Google Corapにリンク)
(大学院課程で、手書きMNISTで実習をしました)
import tensorflow as tf
Sequential: That defines a SEQUENCE of layers in the neural network
Flatten: Remember earlier where our images were a square, when you printed them out? Flatten just takes that square and turns it into a 1 dimensional set.
Dense: Adds a layer of neurons
Each layer of neurons need an activation function to tell them what to do. There's lots of options, but just use these for now.
Relu effectively means "If X>0 return X, else return 0"-- so what it does it it only passes values 0 or greater to the next layer in the network.
Softmax takes a set of values, and effectively picks the biggest one, so, for example, if the output of the last layer looks like [0.1, 0.1, 0.05, 0.1, 9.5, 0.1, 0.05, 0.05, 0.05], it saves you from fishing through it looking for the biggest value, and turns it into [0,0,0,0,1,0,0,0,0] -- The goal is to save a lot of coding!
学習は時間が長いことを発見し、ある程度、私たちが望んでいる正確さに達すれば、私たちはダイヤルして停止することができます.
最初のフェースレイヤ:データのサイズ(ここでは28,28)を入力し、simplelinier arrayに変換します.
最終層:10=10ニューロン=データセットのクラス数に等しい
第2層:hidden layerと呼ばれる層で、relu:0が0未満の場合、0より大きい数値ルールが出力されます.)
すべての答えはここで先生がバニラに行くとありますが、2番の答えはそのままでは間違いです.
Convolutionとはどういう意味ですか.
画像分類時にピクセル値を変換して分類する場合(一番左の画像のように)、余分な部分や不要な部分がある可能性があります.
画像の特徴値を圧縮することで、画像が靴かハンドバッグかシャツかを区別する重要な要素を抽出できます.
上の図の一番左が既存の図であれば、中間の6を基準にして、ボリュームフィルタの値をそれぞれ乗算し、6つの位置に値を加算します(暗黙的に解く必要がなく、図の特徴を抽出することができます).
たとえば、左側の画像が中央のフィルタを通過すると、垂直線の画像が再生成されます.
この融合は力に満ちていて、Poyoungは画像を圧縮する方法の一つです.
4画素中最大の値のみ抽出し、16画素を4画素に圧縮!
そんなにいい
画像からフィーチャー値のみ抽出
サイズが圧縮されます.
このボリュームとプールのコードの適用を取り外して
model = tf.keras.models.Sequential([
tf.keras.layers.Conv2D(64, (3,3), activation='relu',
input_shape=(28, 28, 1)),
4つの授業があるのかと思ったらそうではありませんでした^^..
このコースには4つの講座(各講座には私の多くの講座があります^.)
Introduction to TensorFlow for Artificial Intelligence, Machine Learning, and Deep Learning
Natural Language Processing in TensorFlow
Sequences, Time Series and Prediction
Convolutional Neural Networks in TensorFlow
1.授業内容を整理する
Introduction to TensorFlow for Artificial Intelligence, Machine Learning, and Deep Learning
(これは4つの授業で構成されています)
1-1. 2つの数の関係を検索
既存のプログラミングがルールとデータを入力して結果値を取得している場合.
機械学習は,結果値とデータを入力して繰返しモードを検索し,ルールを導出するプロセスである.
第1の説明では、hellow worldレベルの簡単な例じっけんたんニューロン
import tensorflow as tf
import numpy as np
from tensorflow import keras
def house_model(y_new):
xs = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype=float)
ys = np.array([1.0, 1.5, 2.0, 2.5, 3.0, 3.5], dtype=float)
model = tf.keras.Sequential([keras.layers.Dense(units=1, input_shape=[1])])
model.compile(optimizer='sgd', loss='mean_squared_error')
model.fit(xs, ys, epochs=1000)
return model.predict(y_new)[0]
prediction = house_model([7.0])
print(prediction)
TensorflowとNompikerasを使用したサンプル練習用語
dense : A layer of connected neurons
Optimizer : Figures out how to efficiently compile your code
Loss : Measures how good the current ‘guess’ is_
xs = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype=float)
ys = np.array([1.0, 1.5, 2.0, 2.5, 3.0, 3.5], dtype=float)
house modelという関数を作成して、上記の2つの数の間の(xとy)関係を導出し、1000回(epochs=1000)7.0を訓練し、xが与えられたときにyを導出する.
上は4のはずですが、4に近い値しかありません.
(フォックスが1つ上がるたびにロスは徐々に低下します)
1-2. コンピュータビジョン
Fashion MNISTという名前のデータセットを構築し、AIを学習することで、画像の服のタイプを認識できます。(Google Corapにリンク)
(大学院課程で、手書きMNISTで実習をしました)
import tensorflow as tf
print(tf.__version__)
mnist = tf.keras.datasets.fashion_mnist
#텐서플로우 케라스에서 제공하는 데이터셋API(위의 패션 엠니스트) 가져오기
(training_images, training_labels), (test_images, test_labels) = mnist.load_data()
import numpy as np
np.set_printoptions(linewidth=200)
import matplotlib.pyplot as plt
plt.imshow(training_images[0])
print(training_labels[0])
print(training_images[0])
training_images = training_images / 255.0
test_images = test_images / 255.0
#0이랑 1 사이의 값으로 바꾸기 위함
model = tf.keras.models.Sequential([tf.keras.layers.Flatten(),
tf.keras.layers.Dense(128, activation=tf.nn.relu),
tf.keras.layers.Dense(10, activation=tf.nn.softmax)])
model.compile(optimizer = tf.optimizers.Adam(),
loss = 'sparse_categorical_crossentropy',
metrics=['accuracy'])
model.fit(training_images, training_labels, epochs=5)
#用語Sequential: That defines a SEQUENCE of layers in the neural network
Flatten: Remember earlier where our images were a square, when you printed them out? Flatten just takes that square and turns it into a 1 dimensional set.
Dense: Adds a layer of neurons
Each layer of neurons need an activation function to tell them what to do. There's lots of options, but just use these for now.
Relu effectively means "If X>0 return X, else return 0"-- so what it does it it only passes values 0 or greater to the next layer in the network.
Softmax takes a set of values, and effectively picks the biggest one, so, for example, if the output of the last layer looks like [0.1, 0.1, 0.05, 0.1, 9.5, 0.1, 0.05, 0.05, 0.05], it saves you from fishing through it looking for the biggest value, and turns it into [0,0,0,0,1,0,0,0,0] -- The goal is to save a lot of coding!
学習は時間が長いことを発見し、ある程度、私たちが望んでいる正確さに達すれば、私たちはダイヤルして停止することができます.
class myCallback(tf.keras.callbacks.Callback):
def on_epoch_end(self, epoch, logs={}):
if(logs.get('accuracy')>0.6):
print("\nReached 60% accuracy so cancelling training!")
self.model.stop_training = True
/////콜백 클래스를 선언하고
mnist = tf.keras.datasets.fashion_mnist
(x_train, y_train),(x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0
callbacks = myCallback()
model = tf.keras.models.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28)),
tf.keras.layers.Dense(512, activation=tf.nn.relu),
tf.keras.layers.Dense(10, activation=tf.nn.softmax)
])
model.compile(optimizer=tf.optimizers.Adam(),
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
model.fit(x_train, y_train, epochs=10, callbacks=[callbacks])
///위의 모델에서 콜백 클래스를 불러온다음에 모델의 인스턴스로 넣어주기
model = tf.keras.models.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28)),
tf.keras.layers.Dense(512, activation=tf.nn.relu),
tf.keras.layers.Dense(10, activation=tf.nn.softmax)
])
ここで重要なのは第一面と最後の層です.最初のフェースレイヤ:データのサイズ(ここでは28,28)を入力し、simplelinier arrayに変換します.
最終層:10=10ニューロン=データセットのクラス数に等しい
第2層:hidden layerと呼ばれる層で、relu:0が0未満の場合、0より大きい数値ルールが出力されます.)
練習問題
すべての答えはここで先生がバニラに行くとありますが、2番の答えはそのままでは間違いです.
##### GRADED FUNCTION: train_mnist
def train_mnist():
import tensorflow as tf
class myCallback(tf.keras.callbacks.Callback):
def on_epoch_end(self, epoch, logs={}):
if(logs.get('acc') is not None and logs.get('acc') >= 0.99):
print("\nReached 99% accuracy so cancelling training!")
self.model.stop_training = True
mnist = tf.keras.datasets.mnist
(x_train, y_train),(x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0
callbacks = myCallback()
model = tf.keras.models.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28)),
tf.keras.layers.Dense(512, activation=tf.nn.relu),
tf.keras.layers.Dense(10, activation=tf.nn.softmax)
])
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
history = model.fit(x_train, y_train,epochs=10,callbacks=[callbacks])
# model fitting
return history.epoch, history.history['acc'][-1]
(インデントは自分で見てやって、球体になったところをそう変えて、正しくコンパイルすることができます)1-3. CNN(Convolutional Neural Network)、合成乗ニューラルネットワーク
Convolutionとはどういう意味ですか.
画像分類時にピクセル値を変換して分類する場合(一番左の画像のように)、余分な部分や不要な部分がある可能性があります.
画像の特徴値を圧縮することで、画像が靴かハンドバッグかシャツかを区別する重要な要素を抽出できます.
上の図の一番左が既存の図であれば、中間の6を基準にして、ボリュームフィルタの値をそれぞれ乗算し、6つの位置に値を加算します(暗黙的に解く必要がなく、図の特徴を抽出することができます).
たとえば、左側の画像が中央のフィルタを通過すると、垂直線の画像が再生成されます.
Pooling
この融合は力に満ちていて、Poyoungは画像を圧縮する方法の一つです.
4画素中最大の値のみ抽出し、16画素を4画素に圧縮!
そんなにいい
画像からフィーチャー値のみ抽出
サイズが圧縮されます.
model = tf.keras.models.Sequential([
tf.keras.layers.Conv2D(64, (3,3), activation='relu',
input_shape=(28, 28, 1)),
# conv (64개의 필터 생성,필터는 3*3크기, 실행은 relu(음수 제거), input shape = 28 x 28,
# 끝의 1은 color depth 가 1 byte로 쓸거라는 뜻 = grey scale)
tf.keras.layers.MaxPooling2D(2, 2),
# 위의 Pooling 그림처럼 2x2 필터중에 최댓값을 뽑아낼거니까 maxpooling
# 위의 컨볼루션과 풀링을 한번 더 반복해도 상관 없음
tf.keras.layers.Flatten(),
#dense layer 들어가기 전에 flat하게 만들어주기
tf.keras.layers.Dense(128, activation='relu'),
#dense input layer with 128 neurons
tf.keras.layers.Dense(10, activation='softmax')
#dense output layer with 10 neurons
])
Reference
この問題について(TensorFlow Developer証明書準備プロセス&後期1), 我々は、より多くの情報をここで見つけました https://velog.io/@hyeonkyeong/TensorFlow-Developer-certificate-준비과정-후기テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol