Skip to content

Commit 7498b29

Browse files
authored
Merge pull request #19 from Hiroshiba/follow-chainer2
work correctly on chainer>=2.0.0
2 parents 8f4b11d + bf08d7f commit 7498b29

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

i2v/chainer_i2v.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
import numpy as np
55
from scipy.ndimage import zoom
66
from skimage.transform import resize
7+
import chainer
78
from chainer import Variable
89
from chainer.functions import average_pooling_2d, sigmoid
9-
from chainer.functions.caffe import CaffeFunction
10+
from chainer.links.caffe import CaffeFunction
1011

1112

1213
class ChainerI2V(Illustration2VecBase):
@@ -47,7 +48,8 @@ def _forward(self, inputs, layername):
4748
input_ -= self.mean # subtract mean
4849
input_ = input_.transpose((0, 3, 1, 2)) # (N, H, W, C) -> (N, C, H, W)
4950
x = Variable(input_)
50-
y, = self.net(inputs={'data': x}, outputs=[layername], train=False)
51+
with chainer.using_config('train', False), chainer.using_config('enable_backprop', False):
52+
y, = self.net(inputs={'data': x}, outputs=[layername])
5153
return y
5254

5355
def _extract(self, inputs, layername):

0 commit comments

Comments
 (0)