keras use, function function

1. keras.engine.input_layer.Input()

def Input(shape=None, batch_shape=None,
  name=None, dtype=None, sparse=False,
  tensor=None):

Used to instantiate a keras tensor

 

2. class Dense(Layer):  

keras.layers.Dense(units, activation=None, use_bias=True, kernel_initializer='glorot_uniform', bias_initializer='zeros', kernel_regularizer=None, bias_regularizer=None, activity_regularizer=None, kernel_constraint=None, bias_constraint=None)

def __init__(self, units,
  activation=None,
  use_bias=True,
  kernel_initializer='glorot_uniform',
  bias_initializer='zeros',
  kernel_regularizer=None,
  bias_regularizer=None,
  activity_regularizer=None,
  kernel_constraint=None,
  bias_constraint=None,
  ** kwargs):

Dense is a class for regular densely-connected NN layer.

 

3. from keras.models import Sequential, Model

4. from keras.utils.np_utils import to_categorical

categorical_labels = to_categorical(int_labels, num_classes=None)

Description:

For example, if you have 10 categories, labels of each sample should be a 10-dimensional vector, the vector corresponding to the index value is 1 the rest position is 0.

EXAMPLE:

Android.permission.FACTOR. Assumed vector 100x1 and 100 represents the number of samples, a scalar tag, label this time expanded to 10-dimensional vector, namely: y_test is 100x10.10 dimensional vector, the value of 1 indicates that the sample belongs to this category, another 9 value places are zero.

y_test = to_categorical(y_test, 10)

 

Guess you like

Origin www.cnblogs.com/shencangzaiyunduan/p/11963295.html