• TensorFlow实战笔记(17)---TFlearn


    目录:

    1. 分布式Estimator
      • 自定义模型
      • 建立自己的机器学习Estimator
      • 调节RunConfig运行时的参数
      • Experiment和LearnRunner
    2. 深度学习Estimator
      • 深度神经网络
      • 广度深度模型
    3. 机器学习Estimator
      • 线性/逻辑回归
      • 随机森林
      • K均值聚类
      • 支持向量机
    4. DataFrame
    5. 监督器Monitors
    6. 代码例子

    一、分布式Estimator

    Estimator包含各种机器学习和深度学习的类,用户能直接使用这些高阶类,同时可根据实际的应用需求快速创建自己的子类。

    六、代码例子---TFlearn实现AlexNet

    数据为鲜花数据集 :

    17_Category_Flower 是一个不同种类鲜花的图像数据,包含 17 不同种类的鲜花,每类 80 张该类鲜花的图片,鲜花种类是英国地区常见鲜花。

    代码:

    import tflearn
    from tflearn.layers.core import input_data, dropout, fully_connected
    from tflearn.layers.conv import conv_2d, max_pool_2d
    from tflearn.layers.normalization import local_response_normalization
    from tflearn.layers.estimator import regression 

    import tflearn.datasets.oxflower17 as oxflower17 X, Y = oxflower17.load_data(one_hot=True, resize_pics=(227, 227)) ##此句调用了tflearn文件夹下dataset中oxflower17.py函数,下载数据 #构建AlexNet网络 # Building 'AlexNet' network = input_data(shape=[None, 227, 227, 3]) network = conv_2d(network, 96, 11, strides=4, activation='relu') network = max_pool_2d(network, 3, strides=2) network = local_response_normalization(network) network = conv_2d(network, 256, 5, activation='relu') network = max_pool_2d(network, 3, strides=2) network = local_response_normalization(network) network = conv_2d(network, 384, 3, activation='relu') network = conv_2d(network, 384, 3, activation='relu') network = conv_2d(network, 256, 3, activation='relu') network = max_pool_2d(network, 3, strides=2) network = local_response_normalization(network) network = fully_connected(network, 4096, activation='tanh') network = dropout(network, 0.5) network = fully_connected(network, 4096, activation='tanh') network = dropout(network, 0.5) network = fully_connected(network, 17, activation='softmax') network = regression(network, optimizer='momentum', loss='categorical_crossentropy', learning_rate=0.001) # Training model = tflearn.DNN(network, checkpoint_path='model_alexnet', max_checkpoints=1, tensorboard_verbose=2) model.fit(x, y, n_epoch=1000, validation_set=0.1, shuffle=True, show_metric=True, batch_size=64, snapshot_step=200, snapshot_epoch=False, run_id='alexnet_oxflowers17')
  • 相关阅读:
    LoadRunner 技巧之 集合点设置
    LoadRunner 技巧之 IP欺骗 (推荐)
    JMeter 聚合报告之 90% Line 参数说明
    python基础学习笔记(二)
    LoadRunner 技巧之HTML 与 URL两种录制模式分析
    LoadRunner 技巧之 检查点
    LoadRunner 技巧之 思考时间设置
    一个JSlider的例子
    JApplet添加图片
    java.util.Arrays.asList 的小问题
  • 原文地址:https://www.cnblogs.com/Lee-yl/p/10119289.html
Copyright © 2020-2023  润新知