@@ -58,18 +58,20 @@ Example:
58
58
59
59
handshape_datasets.delete_temporary_files("dataset_id") --> Delete the local files if its exist a .npz file
60
60
61
- ## How to use the dataset in keras?
61
+ ## Training a handshape classifier with Keras
62
62
63
- First, you must to load the dataset
63
+
64
+
65
+ Load the dataset:
64
66
65
67
dataset = handshape_datasets.load(dataset_id, version=ver, delete=supr)
66
68
67
- You could have the input_shape and the number of classes
69
+ Get the input_shape and number of classes:
68
70
69
71
input_shape = self.dataset[0][0].shape
70
72
classes = self.dataset[1]['y'].max() + 1
71
73
72
- Then you must to build a model
74
+ Define a model (using a pretrained MobileNet here):
73
75
74
76
base_model = keras.applications.mobilenet.MobileNet(input_shape=(input_shape[0],self.input_shape[1],3),
75
77
weights='imagenet', include_top=False)
@@ -79,17 +81,14 @@ Then you must to build a model
79
81
model = Model(inputs=base_model.input, outputs=output)
80
82
model.compile(optimizer='Adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
81
83
82
- Its optional to split the dataset for the validation data when fit the model
84
+ Split the dataset intro train/test sets:
83
85
84
86
X_train, X_test, Y_train, Y_test = sklearn.model_selection.train_test_split(self.dataset[0], self.dataset[1]['y'],
85
87
test_size=test_size,
86
88
stratify=self.dataset[1]['y'])
87
89
88
- At last you must to fit the model
89
-
90
- history = model.fit(X_train, Y_train, batch_size=self.batch_size, epochs=self.epochs,
91
- validation_data=(X_test, Y_test))
90
+ Fit the model
92
91
93
- ## How to use Handshape-datasets with Google Colab:
92
+ history = model.fit(X_train, Y_train, batch_size=self.batch_size, epochs=self.epochs, validation_data=(X_test, Y_test))
94
93
95
- https://colab.research.google.com/drive/1kY-YrbegGFVT7NqVaeA4RjXYRVlZiISR?usp=sharing
94
+ [ Full example ] ( https://colab.research.google.com/drive/1kY-YrbegGFVT7NqVaeA4RjXYRVlZiISR?usp=sharing )
0 commit comments