Kaggel Dog Breed Identification
Kaggel Dog Breed Identification
这是Kaggel的Kaggel Dog Breed Identification比赛
本代码使用了mxnet的gluon最新接口。关于gluon可查看其官方文档, https://zh.gluon.ai/, http://gluon.mxnet.io/
将下载的数据解压后, 运行 preprocessing.py 进行数据预处理
运行extract_features.py, 用resnet152_v1和inceptionv3预训练模型提取得到训练图片和测试集的特征向量, 并写入磁盘
def get_features(net, data):
features = []
labels = []
for X, y in tqdm(data):
feature = net.features(X.as_in_context(ctx))
features.append(feature.asnumpy())
labels.append(y.asnumpy())
features = np.concatenate(features, axis=0)
labels = np.concatenate(labels, axis=0)
return features, labels
运行transfer_learning_train.py, 构建简单分类网络,将上一步提取的特征作为网络输入,然后进行训练, 最终在测试集上预测
net = nn.Sequential()
with net.name_scope():
net.add(nn.BatchNorm())
net.add(nn.Dense(1024))
net.add(nn.BatchNorm())
net.add(nn.Activation('relu'))
net.add(nn.Dropout(0.5))
net.add(nn.Dense(120))
最终在kaggle上得分为0.00595, 排名Top6%