コンテンツにスキップ

Quickstart Example

This example demonstrates how to use an implemented model for human activity recognition.

Load the model

Load the MobileNetV2 model, like a tensorflow.keras.applications API:

1
2
3
4
5
6
7
8
import tfgarden

model = tfgarden.applications.MobileNetV2(
    include_top=True,
    weights=None,
    input_shape=(256, 3),
    classes=6
)

Train the model

Train the loaded model as you normally train a keras model:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# compile the model
# before the model is ready for training,
# it needs a few more settings
model.compile(
    optimizer='adam',
    loss='categorical_crossentropy',
    metrics=['accuracy']
)

# Train the model
stack = model.fit(
    train_ds, 
    epochs=100,
    validation_data=valid_ds
)