-
大小: 84KB文件类型: .zip金币: 1下载: 0 次发布日期: 2021-06-06
- 语言: 其他
- 标签:
资源简介
双线性池化(Bilinear pooling)tensorflow版,可以用于细粒度分类
代码片段和文件信息
‘‘‘
This file is used for the first step of the training procedure of Bilinear_CNN
where only last layer of the Bilinear_CNN (DD) model is trained.
Two VGG16 networks are connected at the output of conv5_3 layer to form
a Bilinear_CNN (DD) network and bilinear merging is performed on connect
these two convolutional layers.
No finetuning is performed on the convolutional layers.
Only blinear layers are trained in this first step.
‘‘‘
from __future__ import print_function
import tensorflow as tf
import numpy as np
import tflearn
from tflearn.data_preprocessing import ImagePreprocessing
from tflearn.data_augmentation import ImageAugmentation
import os
from tflearn.data_utils import shuffle
import pickle
from tflearn.data_utils import image_preloader
import h5py
import math
import logging
import random
import time
def random_flip_right_to_left(image_batch):
result = []
for n in range(image_batch.shape[0]):
if bool(random.getrandbits(1)):
result.append(image_batch[n][:::-1:])
else:
result.append(image_batch[n])
return result
class vgg16:
def __init__(self imgs weights=None sess=None):
self.imgs = imgs
self.last_layer_parameters = [] ## Parameters in this list will be optimized when only last layer is being trained
self.parameters = [] ## Parameters in this list will be optimized when whole BCNN network is finetuned
self.convlayers() ## Create Convolutional layers
self.fc_layers() ## Create Fully connected layer
self.weight_file = weights
#self.load_weights(weights sess)
def convlayers(self):
# zero-mean input
with tf.name_scope(‘preprocess‘) as scope:
mean = tf.constant([123.68 116.779 103.939] dtype=tf.float32 shape=[1 1 1 3] name=‘img_mean‘)
images = self.imgs-mean
print(‘Adding Data Augmentation‘)
# conv1_1
with tf.name_scope(‘conv1_1‘) as scope:
kernel = tf.Variable(tf.truncated_normal([3 3 3 64] dtype=tf.float32
stddev=1e-1) trainable=False name=‘weights‘)
conv = tf.nn.conv2d(images kernel [1 1 1 1] padding=‘SAME‘)
biases = tf.Variable(tf.constant(0.0 shape=[64] dtype=tf.float32)
trainable=False name=‘biases‘)
out = tf.nn.bias_add(conv biases)
self.conv1_1 = tf.nn.relu(out name=scope)
self.parameters += [kernel biases]
# conv1_2
with tf.name_scope(‘conv1_2‘) as scope:
kernel = tf.Variable(tf.truncated_normal([3 3 64 64] dtype=tf.float32
stddev=1e-1) trainable=False name=‘weights‘)
conv = tf.nn.conv2d(self.conv1_1 kernel [1 1 1 1] padding=‘SAME‘)
biases = tf
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-07-12 00:59 Bilinear-CNN-TensorFlow-master\
文件 2736 2017-07-12 00:59 Bilinear-CNN-TensorFlow-master\README.md
目录 0 2017-07-12 00:59 Bilinear-CNN-TensorFlow-master\core\
文件 18308 2017-07-12 00:59 Bilinear-CNN-TensorFlow-master\core\bcnn_DD_woft.py
文件 19347 2017-07-12 00:59 Bilinear-CNN-TensorFlow-master\core\bcnn_DD_woft_with_random_crops.py
文件 19885 2017-07-12 00:59 Bilinear-CNN-TensorFlow-master\core\bcnn_finetuning.py
文件 20624 2017-07-12 00:59 Bilinear-CNN-TensorFlow-master\core\bcnn_finetuning_with_random_crops.py
目录 0 2017-07-12 00:59 Bilinear-CNN-TensorFlow-master\predictions\
文件 22690 2017-07-12 00:59 Bilinear-CNN-TensorFlow-master\predictions\FGVC_aircraft_predictions.csv
目录 0 2017-07-12 00:59 Bilinear-CNN-TensorFlow-master\train_test\
文件 286305 2017-07-12 00:59 Bilinear-CNN-TensorFlow-master\train_test\test_data.txt
文件 515491 2017-07-12 00:59 Bilinear-CNN-TensorFlow-master\train_test\train_data.txt
文件 57204 2017-07-12 00:59 Bilinear-CNN-TensorFlow-master\train_test\validation_data.txt
目录 0 2017-07-12 00:59 Bilinear-CNN-TensorFlow-master\utils\
文件 939 2017-07-12 00:59 Bilinear-CNN-TensorFlow-master\utils\create_h5_dataset.py
文件 3474 2017-07-12 00:59 Bilinear-CNN-TensorFlow-master\utils\extract_vgg_weights2dict.py
评论
共有 条评论