• tflearn alexnet iter 10


    他会自己下载数据:

    # -*- coding: utf-8 -*-
    
    """ AlexNet.
    Applying 'Alexnet' to Oxford's 17 Category Flower Dataset classification task.
    References:
        - Alex Krizhevsky, Ilya Sutskever & Geoffrey E. Hinton. ImageNet
        Classification with Deep Convolutional Neural Networks. NIPS, 2012.
        - 17 Category Flower Dataset. Maria-Elena Nilsback and Andrew Zisserman.
    Links:
        - [AlexNet Paper](http://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks.pdf)
        - [Flower Dataset (17)](http://www.robots.ox.ac.uk/~vgg/data/flowers/17/)
    """
    
    from __future__ import division, print_function, absolute_import
    
    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))
    
    # 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,
    model.fit(X, Y, n_epoch=10, validation_set=0.1, shuffle=True,
              show_metric=True, batch_size=64, snapshot_step=200,
    snapshot_epoch=False, run_id='alexnet_oxflowers17')
    model.save('flower-classifier')




    打开tensotboard: tensorboard --logdir=/tmp/tflearn_logs/


    通过tensorboard查看准确率变化以及loss变化,上图是跑了10个epoch的结果。

  • 相关阅读:
    [转]以安装桌面体验功能为例来探索windows2012服务器管理器的新变化
    [转]DPM2012系列之十六:在SCOM2012上集成DPM2012中央控制台
    [转]DPM2012系列之十二:还原exchange2010用户邮件
    Windows Phone Dev Center How to deploy and run a Windows Phone app
    [转].NET StockTrader 6 Sample Application
    [转]DPM2012系列之一:安装Data Protection Manager 2012
    [转]DPM2012系列之二十:保护Windows server 2012
    [转]DPM2012系列之十七:如何将备份文件恢复到网络共享文件夹
    [转]DPM2012系列之十四:备份SQL server 2008R2数据库
    [转]使用SCOM 2012监控网络
  • 原文地址:https://www.cnblogs.com/bonelee/p/8486074.html
Copyright © 2020-2023  润新知