zoukankan      html  css  js  c++  java
  • tensorflow笔记

    tensoflow笔记

    from tensorflow.keras.models import Sequential
    from tensorflow.keras.layers import Input, Dense, Activation, Model
    
    #方法一:
    layers = [Dense(32, input_shape = (784,)),
       Activation('relu'),
       Dense(10),
       Activation('softmax')]
    model = Sequential(layers)
    
    #方法二:
    model = Sequential()
    model.add(Dense(32, input_shape = (784,)))
    model.add(Activation('relu'))
    model.add(Dense(10))
    model.add(Activation('softmax'))
    
    #方法三:
    # 定义输入层,确定输入维度
    input = Input(shape = (784, ))
    # 2个隐含层,每个都有64个神经元,使用relu激活函数,且由上一层作为参数
    x = Dense(64, activation='relu')(input)
    x = Dense(64, activation='relu')(x)
    # 输出层
    y = Dense(10, activation='softmax')(x)
    # 定义模型,指定输入输出
    model = Model(input=input, output=y)
    # 编译模型,指定优化器,损失函数,度量
    model.compile(optimizer='rmsprop', loss='categorical_crossentropy', metrics=['accuracy'])
    # 模型拟合,即训练
    model.fit(data, labels)
    

      

  • 相关阅读:
    进程与线程
    the art of seo(chapter seven)
    the art of seo(chapter six)
    the art of seo(chapter five)
    the art of seo(chapter four)
    the art of seo(chapter three)
    the art of seo(chapter two)
    the art of seo(chapter one)
    Sentinel Cluster流程分析
    Sentinel Core流程分析
  • 原文地址:https://www.cnblogs.com/iupoint/p/14579534.html
Copyright © 2011-2022 走看看