Skip to content

Commit

Permalink
spp
Browse files Browse the repository at this point in the history
  • Loading branch information
yifanjiang19 committed Oct 23, 2017
1 parent 33c6b05 commit 2705293
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
23 changes: 23 additions & 0 deletions .vscode/tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /[email protected]/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.8 //
F ../cnn_with_spp.py /^import torch.nn.functional as F$/;" kind:namespace line:7
SPP_NET ../cnn_with_spp.py /^class SPP_NET(nn.Module):$/;" kind:class line:9
Variable ../cnn_with_spp.py /^from torch.autograd import Variable$/;" kind:namespace line:5
__init__ ../cnn_with_spp.py /^ def __init__(self, opt, input_nc, ndf=64, gpu_ids=[]):$/;" kind:member line:13
cnn_with_spp.py ../cnn_with_spp.py 1;" kind:file line:1
forward ../cnn_with_spp.py /^ def forward(self,x):$/;" kind:member line:33
functools ../cnn_with_spp.py /^import functools$/;" kind:namespace line:4
init ../cnn_with_spp.py /^from torch.nn import init$/;" kind:namespace line:3
nn ../cnn_with_spp.py /^import torch.nn as nn$/;" kind:namespace line:2
nn ../cnn_with_spp.py /^import torch.nn.functional as F$/;" kind:namespace line:7
np ../cnn_with_spp.py /^import numpy as np$/;" kind:namespace line:6
spatial_pyramid_pool ../cnn_with_spp.py /^from spp_layer import spatial_pyramid_pool$/;" kind:namespace line:8
spatial_pyramid_pool ../spp_layer.py /^def spatial_pyramid_pool(self,previous_conv, num_sample, previous_conv_size, out_pool_size):$/;" kind:function line:1
spp_layer.py ../spp_layer.py 1;" kind:file line:1
torch ../cnn_with_spp.py /^import torch$/;" kind:namespace line:1
torch ../cnn_with_spp.py /^import torch.nn as nn$/;" kind:namespace line:2
torch ../cnn_with_spp.py /^import torch.nn.functional as F$/;" kind:namespace line:7
2 changes: 1 addition & 1 deletion cnn_with_spp.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, opt, input_nc, ndf=64, gpu_ids=[]):
self.conv4 = nn.Conv2d(ndf * 4, ndf * 8, 4, 1, 1, bias=False)
self.BN3 = nn.BatchNorm2d(ndf * 8)

self.conv5 = nn.Conv2d(ndf * 8, 1, 4, 1, 0, bias=False)
self.conv5 = nn.Conv2d(ndf * 8, 64, 4, 1, 0, bias=False)
self.fc1 = nn.Linear(10752,4096)
self.fc2 = nn.Linear(4096,1000)

Expand Down
11 changes: 6 additions & 5 deletions spp_layer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import math
def spatial_pyramid_pool(self,previous_conv, num_sample, previous_conv_size, out_pool_size):
'''
previous_conv: a tensor vector of previous convolution layer
Expand All @@ -10,11 +11,11 @@ def spatial_pyramid_pool(self,previous_conv, num_sample, previous_conv_size, out
# print(previous_conv.size())
for i in range(len(out_pool_size)):
# print(previous_conv_size)
h_strd = previous_conv_size[0] / out_pool_size[i]
w_strd = previous_conv_size[1] / out_pool_size[i]
h_wid = previous_conv_size[0] - h_strd * out_pool_size[i] + 1
w_wid = previous_conv_size[1] - w_strd * out_pool_size[i] + 1
maxpool = nn.MaxPool2d((h_wid,w_wid),stride=(h_strd,w_strd))
h_wid = int(math.ceil(previous_conv_size[0] / out_pool_size[i]))
w_wid = int(math.ceil(previous_conv_size[1] / out_pool_size[i]))
h_pad = (h_wid*out_pool_size[i] - previous_conv_size[0] + 1)/2
w_pad = (w_wid*out_pool_size[i] - previous_conv_size[1] + 1)/2
maxpool = nn.MaxPool2d((h_wid, w_wid), stride=(h_wid, w_wid), padding=(h_pad, w_pad))
x = maxpool(previous_conv)
if(i == 0):
spp = x.view(num_sample,-1)
Expand Down

0 comments on commit 2705293

Please sign in to comment.