- 常规操作
- 将整数标签label进行one-hot转换
- 保存与加载模型权重
- 加载mnist数据
- 加载cifar-100数据
- Keras as a simplified interface to TensorFlow
常规操作
1.将整数标签label进行one-hot转换
from keras.utils.np_utils import to_categorical
int_labels = np.arange(10)
categorical_labels = to_categorical(int_labels, num_classes=None)
2.保存与加载模型权重
model.save_weights('my_model_weights.h5',overwrite=True)
model.load_weights('my_model_weights.h5',overwrite=True)
3.加载mnist数据
from keras.datasets import mnist, cifar100
(X_train, y_train), (X_test, y_test) = mnist.load_data()
print('MNIST training data set label distribution', np.bincount(y_train))
print('test distribution', np.bincount(y_test))
4.加载cifar-100数据
from keras.datasets import mnist, cifar100
(X_train, y_train), (X_test, y_test) = cifar100.load_data(label_mode='fine')
y_train = y_train.ravel()
y_test = y_test.ravel()
Keras as a simplified interface to TensorFlow