提交 43a89a95 编写于 作者: littletomatodonkey's avatar littletomatodonkey

fix resnet series

上级 52844f6f
...@@ -20,7 +20,8 @@ import numpy as np ...@@ -20,7 +20,8 @@ import numpy as np
import paddle import paddle
from paddle import ParamAttr from paddle import ParamAttr
import paddle.nn as nn import paddle.nn as nn
from paddle.nn import Conv2d, Pool2D, BatchNorm, Linear, Dropout from paddle.nn import Conv2d, BatchNorm, Linear, Dropout
from paddle.nn import AdaptiveAvgPool2d, MaxPool2d, AvgPool2d
from paddle.nn.initializer import Uniform from paddle.nn.initializer import Uniform
import math import math
...@@ -195,8 +196,7 @@ class ResNet(nn.Layer): ...@@ -195,8 +196,7 @@ class ResNet(nn.Layer):
stride=2, stride=2,
act="relu", act="relu",
name="conv1") name="conv1")
self.pool2d_max = Pool2D( self.pool2d_max = MaxPool2d(kernel_size=3, stride=2, padding=1)
pool_size=3, pool_stride=2, pool_padding=1, pool_type="max")
self.block_list = [] self.block_list = []
if layers >= 50: if layers >= 50:
...@@ -238,8 +238,7 @@ class ResNet(nn.Layer): ...@@ -238,8 +238,7 @@ class ResNet(nn.Layer):
self.block_list.append(basic_block) self.block_list.append(basic_block)
shortcut = True shortcut = True
self.pool2d_avg = Pool2D( self.pool2d_avg = AdaptiveAvgPool2d(1)
pool_size=7, pool_type='avg', global_pooling=True)
self.pool2d_avg_channels = num_channels[-1] * 2 self.pool2d_avg_channels = num_channels[-1] * 2
......
...@@ -18,9 +18,11 @@ from __future__ import print_function ...@@ -18,9 +18,11 @@ from __future__ import print_function
import numpy as np import numpy as np
import paddle import paddle
import paddle.fluid as fluid from paddle import ParamAttr
from paddle.fluid.param_attr import ParamAttr import paddle.nn as nn
from paddle.fluid.dygraph.nn import Conv2D, Pool2D, BatchNorm, Linear, Dropout from paddle.nn import Conv2d, BatchNorm, Linear, Dropout
from paddle.nn import AdaptiveAvgPool2d, MaxPool2d, AvgPool2d
from paddle.nn.initializer import Uniform
import math import math
...@@ -29,7 +31,7 @@ __all__ = [ ...@@ -29,7 +31,7 @@ __all__ = [
] ]
class ConvBNLayer(fluid.dygraph.Layer): class ConvBNLayer(nn.Layer):
def __init__(self, def __init__(self,
num_channels, num_channels,
num_filters, num_filters,
...@@ -40,15 +42,14 @@ class ConvBNLayer(fluid.dygraph.Layer): ...@@ -40,15 +42,14 @@ class ConvBNLayer(fluid.dygraph.Layer):
name=None): name=None):
super(ConvBNLayer, self).__init__() super(ConvBNLayer, self).__init__()
self._conv = Conv2D( self._conv = Conv2d(
num_channels=num_channels, in_channels=num_channels,
num_filters=num_filters, out_channels=num_filters,
filter_size=filter_size, kernel_size=filter_size,
stride=stride, stride=stride,
padding=(filter_size - 1) // 2, padding=(filter_size - 1) // 2,
groups=groups, groups=groups,
act=None, weight_attr=ParamAttr(name=name + "_weights"),
param_attr=ParamAttr(name=name + "_weights"),
bias_attr=False) bias_attr=False)
if name == "conv1": if name == "conv1":
bn_name = "bn_" + name bn_name = "bn_" + name
...@@ -68,7 +69,7 @@ class ConvBNLayer(fluid.dygraph.Layer): ...@@ -68,7 +69,7 @@ class ConvBNLayer(fluid.dygraph.Layer):
return y return y
class BottleneckBlock(fluid.dygraph.Layer): class BottleneckBlock(nn.Layer):
def __init__(self, def __init__(self,
num_channels, num_channels,
num_filters, num_filters,
...@@ -119,11 +120,11 @@ class BottleneckBlock(fluid.dygraph.Layer): ...@@ -119,11 +120,11 @@ class BottleneckBlock(fluid.dygraph.Layer):
else: else:
short = self.short(inputs) short = self.short(inputs)
y = fluid.layers.elementwise_add(x=short, y=conv2, act='relu') y = paddle.elementwise_add(x=short, y=conv2, act='relu')
return y return y
class BasicBlock(fluid.dygraph.Layer): class BasicBlock(nn.Layer):
def __init__(self, def __init__(self,
num_channels, num_channels,
num_filters, num_filters,
...@@ -164,11 +165,11 @@ class BasicBlock(fluid.dygraph.Layer): ...@@ -164,11 +165,11 @@ class BasicBlock(fluid.dygraph.Layer):
short = inputs short = inputs
else: else:
short = self.short(inputs) short = self.short(inputs)
y = fluid.layers.elementwise_add(x=short, y=conv1, act='relu') y = paddle.elementwise_add(x=short, y=conv1, act='relu')
return y return y
class ResNet_vc(fluid.dygraph.Layer): class ResNet_vc(nn.Layer):
def __init__(self, layers=50, class_dim=1000): def __init__(self, layers=50, class_dim=1000):
super(ResNet_vc, self).__init__() super(ResNet_vc, self).__init__()
...@@ -212,8 +213,7 @@ class ResNet_vc(fluid.dygraph.Layer): ...@@ -212,8 +213,7 @@ class ResNet_vc(fluid.dygraph.Layer):
act='relu', act='relu',
name="conv1_3") name="conv1_3")
self.pool2d_max = Pool2D( self.pool2d_max = MaxPool2d(kernel_size=3, stride=2, padding=1)
pool_size=3, pool_stride=2, pool_padding=1, pool_type='max')
self.block_list = [] self.block_list = []
if layers >= 50: if layers >= 50:
...@@ -255,8 +255,7 @@ class ResNet_vc(fluid.dygraph.Layer): ...@@ -255,8 +255,7 @@ class ResNet_vc(fluid.dygraph.Layer):
self.block_list.append(basic_block) self.block_list.append(basic_block)
shortcut = True shortcut = True
self.pool2d_avg = Pool2D( self.pool2d_avg = AdaptiveAvgPool2d(1)
pool_size=7, pool_type='avg', global_pooling=True)
self.pool2d_avg_channels = num_channels[-1] * 2 self.pool2d_avg_channels = num_channels[-1] * 2
...@@ -265,9 +264,8 @@ class ResNet_vc(fluid.dygraph.Layer): ...@@ -265,9 +264,8 @@ class ResNet_vc(fluid.dygraph.Layer):
self.out = Linear( self.out = Linear(
self.pool2d_avg_channels, self.pool2d_avg_channels,
class_dim, class_dim,
param_attr=ParamAttr( weight_attr=ParamAttr(
initializer=fluid.initializer.Uniform(-stdv, stdv), initializer=Uniform(-stdv, stdv), name="fc_0.w_0"),
name="fc_0.w_0"),
bias_attr=ParamAttr(name="fc_0.b_0")) bias_attr=ParamAttr(name="fc_0.b_0"))
def forward(self, inputs): def forward(self, inputs):
...@@ -278,7 +276,7 @@ class ResNet_vc(fluid.dygraph.Layer): ...@@ -278,7 +276,7 @@ class ResNet_vc(fluid.dygraph.Layer):
for block in self.block_list: for block in self.block_list:
y = block(y) y = block(y)
y = self.pool2d_avg(y) y = self.pool2d_avg(y)
y = fluid.layers.reshape(y, shape=[-1, self.pool2d_avg_channels]) y = paddle.reshape(y, shape=[-1, self.pool2d_avg_channels])
y = self.out(y) y = self.out(y)
return y return y
......
...@@ -18,9 +18,11 @@ from __future__ import print_function ...@@ -18,9 +18,11 @@ from __future__ import print_function
import numpy as np import numpy as np
import paddle import paddle
import paddle.fluid as fluid from paddle import ParamAttr
from paddle.fluid.param_attr import ParamAttr import paddle.nn as nn
from paddle.fluid.dygraph.nn import Conv2D, Pool2D, BatchNorm, Linear, Dropout from paddle.nn import Conv2d, BatchNorm, Linear, Dropout
from paddle.nn import AdaptiveAvgPool2d, MaxPool2d, AvgPool2d
from paddle.nn.initializer import Uniform
import math import math
...@@ -29,7 +31,7 @@ __all__ = [ ...@@ -29,7 +31,7 @@ __all__ = [
] ]
class ConvBNLayer(fluid.dygraph.Layer): class ConvBNLayer(nn.Layer):
def __init__( def __init__(
self, self,
num_channels, num_channels,
...@@ -43,21 +45,16 @@ class ConvBNLayer(fluid.dygraph.Layer): ...@@ -43,21 +45,16 @@ class ConvBNLayer(fluid.dygraph.Layer):
super(ConvBNLayer, self).__init__() super(ConvBNLayer, self).__init__()
self.is_vd_mode = is_vd_mode self.is_vd_mode = is_vd_mode
self._pool2d_avg = Pool2D( self._pool2d_avg = AvgPool2d(
pool_size=2, kernel_size=2, stride=2, padding=0, ceil_mode=True)
pool_stride=2, self._conv = Conv2d(
pool_padding=0, in_channels=num_channels,
pool_type='avg', out_channels=num_filters,
ceil_mode=True) kernel_size=filter_size,
self._conv = Conv2D(
num_channels=num_channels,
num_filters=num_filters,
filter_size=filter_size,
stride=stride, stride=stride,
padding=(filter_size - 1) // 2, padding=(filter_size - 1) // 2,
groups=groups, groups=groups,
act=None, weight_attr=ParamAttr(name=name + "_weights"),
param_attr=ParamAttr(name=name + "_weights"),
bias_attr=False) bias_attr=False)
if name == "conv1": if name == "conv1":
bn_name = "bn_" + name bn_name = "bn_" + name
...@@ -79,7 +76,7 @@ class ConvBNLayer(fluid.dygraph.Layer): ...@@ -79,7 +76,7 @@ class ConvBNLayer(fluid.dygraph.Layer):
return y return y
class BottleneckBlock(fluid.dygraph.Layer): class BottleneckBlock(nn.Layer):
def __init__(self, def __init__(self,
num_channels, num_channels,
num_filters, num_filters,
...@@ -129,11 +126,11 @@ class BottleneckBlock(fluid.dygraph.Layer): ...@@ -129,11 +126,11 @@ class BottleneckBlock(fluid.dygraph.Layer):
short = inputs short = inputs
else: else:
short = self.short(inputs) short = self.short(inputs)
y = fluid.layers.elementwise_add(x=short, y=conv2, act='relu') y = paddle.elementwise_add(x=short, y=conv2, act='relu')
return y return y
class BasicBlock(fluid.dygraph.Layer): class BasicBlock(nn.Layer):
def __init__(self, def __init__(self,
num_channels, num_channels,
num_filters, num_filters,
...@@ -176,11 +173,11 @@ class BasicBlock(fluid.dygraph.Layer): ...@@ -176,11 +173,11 @@ class BasicBlock(fluid.dygraph.Layer):
short = inputs short = inputs
else: else:
short = self.short(inputs) short = self.short(inputs)
y = fluid.layers.elementwise_add(x=short, y=conv1, act='relu') y = paddle.elementwise_add(x=short, y=conv1, act='relu')
return y return y
class ResNet_vd(fluid.dygraph.Layer): class ResNet_vd(nn.Layer):
def __init__(self, layers=50, class_dim=1000): def __init__(self, layers=50, class_dim=1000):
super(ResNet_vd, self).__init__() super(ResNet_vd, self).__init__()
...@@ -225,8 +222,7 @@ class ResNet_vd(fluid.dygraph.Layer): ...@@ -225,8 +222,7 @@ class ResNet_vd(fluid.dygraph.Layer):
stride=1, stride=1,
act='relu', act='relu',
name="conv1_3") name="conv1_3")
self.pool2d_max = Pool2D( self.pool2d_max = MaxPool2d(kernel_size=3, stride=2, padding=1)
pool_size=3, pool_stride=2, pool_padding=1, pool_type='max')
self.block_list = [] self.block_list = []
if layers >= 50: if layers >= 50:
...@@ -270,8 +266,7 @@ class ResNet_vd(fluid.dygraph.Layer): ...@@ -270,8 +266,7 @@ class ResNet_vd(fluid.dygraph.Layer):
self.block_list.append(basic_block) self.block_list.append(basic_block)
shortcut = True shortcut = True
self.pool2d_avg = Pool2D( self.pool2d_avg = AdaptiveAvgPool2d(1)
pool_size=7, pool_type='avg', global_pooling=True)
self.pool2d_avg_channels = num_channels[-1] * 2 self.pool2d_avg_channels = num_channels[-1] * 2
...@@ -280,9 +275,8 @@ class ResNet_vd(fluid.dygraph.Layer): ...@@ -280,9 +275,8 @@ class ResNet_vd(fluid.dygraph.Layer):
self.out = Linear( self.out = Linear(
self.pool2d_avg_channels, self.pool2d_avg_channels,
class_dim, class_dim,
param_attr=ParamAttr( weight_attr=ParamAttr(
initializer=fluid.initializer.Uniform(-stdv, stdv), initializer=Uniform(-stdv, stdv), name="fc_0.w_0"),
name="fc_0.w_0"),
bias_attr=ParamAttr(name="fc_0.b_0")) bias_attr=ParamAttr(name="fc_0.b_0"))
def forward(self, inputs): def forward(self, inputs):
...@@ -293,7 +287,7 @@ class ResNet_vd(fluid.dygraph.Layer): ...@@ -293,7 +287,7 @@ class ResNet_vd(fluid.dygraph.Layer):
for block in self.block_list: for block in self.block_list:
y = block(y) y = block(y)
y = self.pool2d_avg(y) y = self.pool2d_avg(y)
y = fluid.layers.reshape(y, shape=[-1, self.pool2d_avg_channels]) y = paddle.reshape(y, shape=[-1, self.pool2d_avg_channels])
y = self.out(y) y = self.out(y)
return y return y
......
...@@ -18,9 +18,11 @@ from __future__ import print_function ...@@ -18,9 +18,11 @@ from __future__ import print_function
import numpy as np import numpy as np
import paddle import paddle
import paddle.fluid as fluid from paddle import ParamAttr
from paddle.fluid.param_attr import ParamAttr import paddle.nn as nn
from paddle.fluid.dygraph.nn import Conv2D, Pool2D, BatchNorm, Linear, Dropout from paddle.nn import Conv2d, BatchNorm, Linear, Dropout
from paddle.nn import AdaptiveAvgPool2d, MaxPool2d, AvgPool2d
from paddle.nn.initializer import Uniform
import math import math
...@@ -30,7 +32,7 @@ __all__ = [ ...@@ -30,7 +32,7 @@ __all__ = [
] ]
class ConvBNLayer(fluid.dygraph.Layer): class ConvBNLayer(nn.Layer):
def __init__(self, def __init__(self,
num_channels, num_channels,
num_filters, num_filters,
...@@ -41,15 +43,14 @@ class ConvBNLayer(fluid.dygraph.Layer): ...@@ -41,15 +43,14 @@ class ConvBNLayer(fluid.dygraph.Layer):
name=None): name=None):
super(ConvBNLayer, self).__init__() super(ConvBNLayer, self).__init__()
self._conv = Conv2D( self._conv = Conv2d(
num_channels=num_channels, in_channels=num_channels,
num_filters=num_filters, out_channels=num_filters,
filter_size=filter_size, kernel_size=filter_size,
stride=stride, stride=stride,
padding=(filter_size - 1) // 2, padding=(filter_size - 1) // 2,
groups=groups, groups=groups,
act=None, weight_attr=ParamAttr(name=name + "_weights"),
param_attr=ParamAttr(name=name + "_weights"),
bias_attr=False) bias_attr=False)
if name == "conv1": if name == "conv1":
bn_name = "bn_" + name bn_name = "bn_" + name
...@@ -69,7 +70,7 @@ class ConvBNLayer(fluid.dygraph.Layer): ...@@ -69,7 +70,7 @@ class ConvBNLayer(fluid.dygraph.Layer):
return y return y
class BottleneckBlock(fluid.dygraph.Layer): class BottleneckBlock(nn.Layer):
def __init__(self, def __init__(self,
num_channels, num_channels,
num_filters, num_filters,
...@@ -121,11 +122,11 @@ class BottleneckBlock(fluid.dygraph.Layer): ...@@ -121,11 +122,11 @@ class BottleneckBlock(fluid.dygraph.Layer):
else: else:
short = self.short(inputs) short = self.short(inputs)
y = fluid.layers.elementwise_add(x=short, y=conv2, act='relu') y = paddle.elementwise_add(x=short, y=conv2, act='relu')
return y return y
class ResNeXt(fluid.dygraph.Layer): class ResNeXt(nn.Layer):
def __init__(self, layers=50, class_dim=1000, cardinality=32): def __init__(self, layers=50, class_dim=1000, cardinality=32):
super(ResNeXt, self).__init__() super(ResNeXt, self).__init__()
...@@ -156,8 +157,7 @@ class ResNeXt(fluid.dygraph.Layer): ...@@ -156,8 +157,7 @@ class ResNeXt(fluid.dygraph.Layer):
stride=2, stride=2,
act='relu', act='relu',
name="res_conv1") name="res_conv1")
self.pool2d_max = Pool2D( self.pool2d_max = MaxPool2d(kernel_size=3, stride=2, padding=1)
pool_size=3, pool_stride=2, pool_padding=1, pool_type='max')
self.block_list = [] self.block_list = []
for block in range(len(depth)): for block in range(len(depth)):
...@@ -183,8 +183,7 @@ class ResNeXt(fluid.dygraph.Layer): ...@@ -183,8 +183,7 @@ class ResNeXt(fluid.dygraph.Layer):
self.block_list.append(bottleneck_block) self.block_list.append(bottleneck_block)
shortcut = True shortcut = True
self.pool2d_avg = Pool2D( self.pool2d_avg = AdaptiveAvgPool2d(1)
pool_size=7, pool_type='avg', global_pooling=True)
self.pool2d_avg_channels = num_channels[-1] * 2 self.pool2d_avg_channels = num_channels[-1] * 2
...@@ -193,9 +192,8 @@ class ResNeXt(fluid.dygraph.Layer): ...@@ -193,9 +192,8 @@ class ResNeXt(fluid.dygraph.Layer):
self.out = Linear( self.out = Linear(
self.pool2d_avg_channels, self.pool2d_avg_channels,
class_dim, class_dim,
param_attr=ParamAttr( weight_attr=ParamAttr(
initializer=fluid.initializer.Uniform(-stdv, stdv), initializer=Uniform(-stdv, stdv), name="fc_weights"),
name="fc_weights"),
bias_attr=ParamAttr(name="fc_offset")) bias_attr=ParamAttr(name="fc_offset"))
def forward(self, inputs): def forward(self, inputs):
...@@ -204,7 +202,7 @@ class ResNeXt(fluid.dygraph.Layer): ...@@ -204,7 +202,7 @@ class ResNeXt(fluid.dygraph.Layer):
for block in self.block_list: for block in self.block_list:
y = block(y) y = block(y)
y = self.pool2d_avg(y) y = self.pool2d_avg(y)
y = fluid.layers.reshape(y, shape=[-1, self.pool2d_avg_channels]) y = paddle.reshape(y, shape=[-1, self.pool2d_avg_channels])
y = self.out(y) y = self.out(y)
return y return y
......
...@@ -18,9 +18,11 @@ from __future__ import print_function ...@@ -18,9 +18,11 @@ from __future__ import print_function
import numpy as np import numpy as np
import paddle import paddle
import paddle.fluid as fluid from paddle import ParamAttr
from paddle.fluid.param_attr import ParamAttr import paddle.nn as nn
from paddle.fluid.dygraph.nn import Conv2D, Pool2D, BatchNorm, Linear, Dropout from paddle.nn import Conv2d, BatchNorm, Linear, Dropout
from paddle.nn import AdaptiveAvgPool2d, MaxPool2d, AvgPool2d
from paddle.nn.initializer import Uniform
import math import math
...@@ -30,7 +32,7 @@ __all__ = [ ...@@ -30,7 +32,7 @@ __all__ = [
] ]
class ConvBNLayer(fluid.dygraph.Layer): class ConvBNLayer(nn.Layer):
def __init__( def __init__(
self, self,
num_channels, num_channels,
...@@ -44,21 +46,16 @@ class ConvBNLayer(fluid.dygraph.Layer): ...@@ -44,21 +46,16 @@ class ConvBNLayer(fluid.dygraph.Layer):
super(ConvBNLayer, self).__init__() super(ConvBNLayer, self).__init__()
self.is_vd_mode = is_vd_mode self.is_vd_mode = is_vd_mode
self._pool2d_avg = Pool2D( self._pool2d_avg = AvgPool2d(
pool_size=2, kernel_size=2, stride=2, padding=0, ceil_mode=True)
pool_stride=2, self._conv = Conv2d(
pool_padding=0, in_channels=num_channels,
pool_type='avg', out_channels=num_filters,
ceil_mode=True) kernel_size=filter_size,
self._conv = Conv2D(
num_channels=num_channels,
num_filters=num_filters,
filter_size=filter_size,
stride=stride, stride=stride,
padding=(filter_size - 1) // 2, padding=(filter_size - 1) // 2,
groups=groups, groups=groups,
act=None, weight_attr=ParamAttr(name=name + "_weights"),
param_attr=ParamAttr(name=name + "_weights"),
bias_attr=False) bias_attr=False)
if name == "conv1": if name == "conv1":
bn_name = "bn_" + name bn_name = "bn_" + name
...@@ -80,7 +77,7 @@ class ConvBNLayer(fluid.dygraph.Layer): ...@@ -80,7 +77,7 @@ class ConvBNLayer(fluid.dygraph.Layer):
return y return y
class BottleneckBlock(fluid.dygraph.Layer): class BottleneckBlock(nn.Layer):
def __init__(self, def __init__(self,
num_channels, num_channels,
num_filters, num_filters,
...@@ -134,11 +131,11 @@ class BottleneckBlock(fluid.dygraph.Layer): ...@@ -134,11 +131,11 @@ class BottleneckBlock(fluid.dygraph.Layer):
else: else:
short = self.short(inputs) short = self.short(inputs)
y = fluid.layers.elementwise_add(x=short, y=conv2, act='relu') y = paddle.elementwise_add(x=short, y=conv2, act='relu')
return y return y
class ResNeXt(fluid.dygraph.Layer): class ResNeXt(nn.Layer):
def __init__(self, layers=50, class_dim=1000, cardinality=32): def __init__(self, layers=50, class_dim=1000, cardinality=32):
super(ResNeXt, self).__init__() super(ResNeXt, self).__init__()
...@@ -184,8 +181,7 @@ class ResNeXt(fluid.dygraph.Layer): ...@@ -184,8 +181,7 @@ class ResNeXt(fluid.dygraph.Layer):
act='relu', act='relu',
name="conv1_3") name="conv1_3")
self.pool2d_max = Pool2D( self.pool2d_max = MaxPool2d(kernel_size=3, stride=2, padding=1)
pool_size=3, pool_stride=2, pool_padding=1, pool_type='max')
self.block_list = [] self.block_list = []
for block in range(len(depth)): for block in range(len(depth)):
...@@ -212,8 +208,7 @@ class ResNeXt(fluid.dygraph.Layer): ...@@ -212,8 +208,7 @@ class ResNeXt(fluid.dygraph.Layer):
self.block_list.append(bottleneck_block) self.block_list.append(bottleneck_block)
shortcut = True shortcut = True
self.pool2d_avg = Pool2D( self.pool2d_avg = AdaptiveAvgPool2d(1)
pool_size=7, pool_type='avg', global_pooling=True)
self.pool2d_avg_channels = num_channels[-1] * 2 self.pool2d_avg_channels = num_channels[-1] * 2
...@@ -222,9 +217,8 @@ class ResNeXt(fluid.dygraph.Layer): ...@@ -222,9 +217,8 @@ class ResNeXt(fluid.dygraph.Layer):
self.out = Linear( self.out = Linear(
self.pool2d_avg_channels, self.pool2d_avg_channels,
class_dim, class_dim,
param_attr=ParamAttr( weight_attr=ParamAttr(
initializer=fluid.initializer.Uniform(-stdv, stdv), initializer=Uniform(-stdv, stdv), name="fc_weights"),
name="fc_weights"),
bias_attr=ParamAttr(name="fc_offset")) bias_attr=ParamAttr(name="fc_offset"))
def forward(self, inputs): def forward(self, inputs):
...@@ -235,7 +229,7 @@ class ResNeXt(fluid.dygraph.Layer): ...@@ -235,7 +229,7 @@ class ResNeXt(fluid.dygraph.Layer):
for block in self.block_list: for block in self.block_list:
y = block(y) y = block(y)
y = self.pool2d_avg(y) y = self.pool2d_avg(y)
y = fluid.layers.reshape(y, shape=[-1, self.pool2d_avg_channels]) y = paddle.reshape(y, shape=[-1, self.pool2d_avg_channels])
y = self.out(y) y = self.out(y)
return y return y
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册