Keras learning (Introduction)

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/dreamLC1998/article/details/102704455

Keras: Based on the depth of learning Python library

Brief introduction

Keras written in Python is a high-level neural network API, it can TensorFlow, CNTK, or Theano run as the back end. Keras's development focus is to support the rapid test. With minimal delay to convert your ideas into results, it is the key to good research.

keras (deep learning framework)

Summary of the training process
1. Download and read datasets
from keras.datasets import 数据集 
(x_train, y_train), (x_test, y_test) = 数据集.load_data()
2. The test data to quantify
  • Training and test data to quantify
    • x_train.astype('float32')
  • Tag to quantization (onehot coding)
    • to_categorical(y, num_classes=None, dtype='float32')
      • The integer class label into onehot coding. y is int array, num_classes category is the number of tags is greater than max (y) (label starting from 0)
      • Returns: If num_classes = None, return len (y) * [max (y) +1] (dimensions, m represents the m * n matrix of rows and n columns, the same below), otherwise len (y) * num_classes)
3. Build Network

from keras.models

from keras.layers

Keras There are two types of models, sequential model (the Sequential) and functional model (the Model), functional model applied more widely, the sequential model is a functional model is a special case.

  • a) Sequential Model (Sequential): single input single output, a road leads in the end, only the relationship between adjacent layers, there is no cross-connection layer. This model compiler is fast, the operation is relatively simple

  • b) functional model (Model): multiple input multiple output, any connection between the layers. This model is compiled slow.

Step1: model=models.Sequential(): generating a model, on the basis of the various layers applied

SETP2: model.add: Add layer;

step3: model.compilecompilation model

step4: model.fitmodel training parameters + training;

Guess you like

Origin blog.csdn.net/dreamLC1998/article/details/102704455