目录:
- 分布式Estimator
- 自定义模型
- 建立自己的机器学习Estimator
- 调节RunConfig运行时的参数
- Experiment和LearnRunner
- 深度学习Estimator
- 深度神经网络
- 广度深度模型
- 机器学习Estimator
- 线性/逻辑回归
- 随机森林
- K均值聚类
- 支持向量机
- DataFrame
- 监督器Monitors
- 代码例子
一、分布式Estimator
Estimator包含各种机器学习和深度学习的类,用户能直接使用这些高阶类,同时可根据实际的应用需求快速创建自己的子类。
六、代码例子---TFlearn实现AlexNet
数据为鲜花数据集 :
17_Category_Flower 是一个不同种类鲜花的图像数据,包含 17 不同种类的鲜花,每类 80 张该类鲜花的图片,鲜花种类是英国地区常见鲜花。
代码:
import tflearnfrom tflearn.layers.core import input_data, dropout, fully_connectedfrom tflearn.layers.conv import conv_2d, max_pool_2dfrom tflearn.layers.normalization import local_response_normalizationfrom tflearn.layers.estimator import regression import tflearn.datasets.oxflower17 as oxflower17X, 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) # Trainingmodel = 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')