Kerasのモデル
この演習では、keras.models モジュールにある2つのクラスの使い方を練習します。Sequential クラスで1つのモデルを作成し、Model クラスでもう1つのモデルを作成します。
Sequential クラスはレイヤーが順番どおりに積み重なる前提なので扱いやすい一方、Model クラスはより柔軟で、複数入力・複数出力やレイヤーの共有(重みの共有)に対応しています。
Model クラスでは入力レイヤーを明示的に宣言する必要がありますが、Sequential クラスでは input_shape パラメータで指定します。
Sequential、Model、Dense、Input、LSTM、np(numpy)はすでに環境に読み込まれています。
この演習はコースの一部です
Kerasで学ぶ言語モデリングのためのRecurrent Neural Networks (RNNs)
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# Instantiate the class
model = ____(name="sequential_model")
# One LSTM layer (defining the input shape because it is the
# initial layer)
model.add(____(128, input_shape=(None, 10), name="LSTM"))
# Add a dense layer with one unit
model.add(____(1, activation="sigmoid", name="output"))
# The summary shows the layers and the number of parameters
# that will be trained
model.____