ニューラルネットワーク作成のプログラム例
37
import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Activation
m = tf.keras.models.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28, 1)),
tf.keras.layers.Dense(units=64, activation=tf.nn.relu),
tf.keras.layers.Dense(units=10, activation=tf.nn.softmax)
])
1層目のニューロン数は 64
種類は relu
2層目のニューロン数は 10
種類は softmax
入力データは 28×28個の数字