资源简介
官方例子,深度学习专用,机器学习专用,代码简单,一看就会(keras inception v4 finetune)
代码片段和文件信息
# -*- coding: utf-8 -*-
from keras.models import Sequential
from keras.optimizers import SGD
from keras.layers import Input Dense Convolution2D MaxPooling2D AveragePooling2D ZeroPadding2D Dropout Flatten merge Reshape Activation
from keras.layers.normalization import BatchNormalization
from keras.models import Model
from keras import backend as K
from sklearn.metrics import log_loss
from load_cifar10 import load_cifar10_data
def conv2d_bn(x nb_filter nb_row nb_col
border_mode=‘same‘ subsample=(1 1) bias=False):
“““
Utility function to apply conv + BN.
(Slightly modified from https://github.com/fchollet/keras/blob/master/keras/applications/inception_v3.py)
“““
if K.image_dim_ordering() == “th“:
channel_axis = 1
else:
channel_axis = -1
x = Convolution2D(nb_filter nb_row nb_col
subsample=subsample
border_mode=border_mode
bias=bias)(x)
x = BatchNormalization(axis=channel_axis)(x)
x = Activation(‘relu‘)(x)
return x
def block_inception_a(input):
if K.image_dim_ordering() == “th“:
channel_axis = 1
else:
channel_axis = -1
branch_0 = conv2d_bn(input 96 1 1)
branch_1 = conv2d_bn(input 64 1 1)
branch_1 = conv2d_bn(branch_1 96 3 3)
branch_2 = conv2d_bn(input 64 1 1)
branch_2 = conv2d_bn(branch_2 96 3 3)
branch_2 = conv2d_bn(branch_2 96 3 3)
branch_3 = AveragePooling2D((33) strides=(11) border_mode=‘same‘)(input)
branch_3 = conv2d_bn(branch_3 96 1 1)
x = merge([branch_0 branch_1 branch_2 branch_3] mode=‘concat‘ concat_axis=channel_axis)
return x
def block_reduction_a(input):
if K.image_dim_ordering() == “th“:
channel_axis = 1
else:
channel_axis = -1
branch_0 = conv2d_bn(input 384 3 3 subsample=(22) border_mode=‘valid‘)
branch_1 = conv2d_bn(input 192 1 1)
branch_1 = conv2d_bn(branch_1 224 3 3)
branch_1 = conv2d_bn(branch_1 256 3 3 subsample=(22) border_mode=‘valid‘)
branch_2 = MaxPooling2D((33) strides=(22) border_mode=‘valid‘)(input)
x = merge([branch_0 branch_1 branch_2] mode=‘concat‘ concat_axis=channel_axis)
return x
def block_inception_b(input):
if K.image_dim_ordering() == “th“:
channel_axis = 1
else:
channel_axis = -1
branch_0 = conv2d_bn(input 384 1 1)
branch_1 = conv2d_bn(input 192 1 1)
branch_1 = conv2d_bn(branch_1 224 1 7)
branch_1 = conv2d_bn(branch_1 256 7 1)
branch_2 = conv2d_bn(input 192 1 1)
branch_2 = conv2d_bn(branch_2 192 7 1)
branch_2 = conv2d_bn(branch_2 224 1 7)
branch_2 = conv2d_bn(branch_2 224 7 1)
branch_2 = conv2d_bn(branch_2 256 1 7)
branch_3 = AveragePooling2D((33) strides=(11) border_mode=‘same‘)(input)
branch_3 = conv2d_bn(branch_3 128 1 1)
x = merge([branch_0 branch_1 branch_2
相关资源
- tensorflow_random_forest_demo.py
- densenet121.py
- mnist_acgan.py
- 集成k-最近邻(k-NN)、朴素贝叶斯、
- Python-机器学习完全课程
- Python-Glyce用于汉字表示的字形向量
- 燕大《Python机器学习》实验报告 .do
- 卷积神经网络轴承数故障分类
- python实现谱聚类代码并进行可视化
- 机器学习-python处理UCI鲍鱼数据集.ra
- 利用贝叶斯算法实现垃圾邮件分类
- 利用鸢尾花数据集画出P-R曲线 pytho
- 实战python利用线性回归来预测鲍鱼年
- 实战python线性回归
- python图像裁剪
- 使用训练好的模型进行预测
- Python→Transorflow猫狗识别完整代码,附
- FaceClustering.zip
- Python-RNNoiseRNN音频噪声抑制学习
- Python-Keras实现实时语义分割的深层神
- Python-手势识别使用在TensorFlow中卷积神
- python 机器学习之支持向量机非线性回
- datingTestSet2.txt
- 多层BP神经网络参数高自由度Python
- 目标检测自动标注代码
- 梯度下降python程序实现+可视化
- 基于深度学习的表情识别系统
- 语义分割标注转为目标检测框标注
- keras上LSTM长短期记忆网络金融时序预
- 二项分布的代码可视化实现
评论
共有 条评论