tensorflow.keras
在keras中,可以通过组合层来构建模型。模型是由层构成的图。最常见的模型类型是层的堆叠: tf.keras.Sequential . model = tf.keras.Sequential() # Adds a densely-connected layer with 64 units to the model: model.add(layers.Dense(64, activation='relu')) # Add another: model.add(layers.Dense(64, activation='relu')) # Add a softmax layer with 10 output units: model.add(layers.Dense(10, activation='softmax')) tf.keras.layers的参数,activation:激活函数,由内置函数的名称指定,或指定为可用的调用对象。kernel_initializer和bias_initializer:层权重的初始化方案。名称或可调用对象。kernel_regularizer和bias_regularizer:层权重的正则化方案。 # Create a sigmoid layer: layers.Dense(64, activation='sigmoid') # Or: layers