prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  resnet模型配置的问题
  目前resnet的配置有一些问题，可见 https://github.com/PaddlePaddle/models/issues/308#issuecomment-331384031
  
  </issue>
  <code>
  [start of image_classification/resnet.py]
  1 import paddle.v2 as paddle
  2 
  3 __all__ = ['resnet_imagenet', 'resnet_cifar10']
  4 
  5 
  6 def conv_bn_layer(input,
  7                   ch_out,
  8                   filter_size,
  9                   stride,
  10                   padding,
  11                   active_type=paddle.activation.Relu(),
  12                   ch_in=None):
  13     tmp = paddle.layer.img_conv(
  14         input=input,
  15         filter_size=filter_size,
  16         num_channels=ch_in,
  17         num_filters=ch_out,
  18         stride=stride,
  19         padding=padding,
  20         act=paddle.activation.Linear(),
  21         bias_attr=False)
  22     return paddle.layer.batch_norm(input=tmp, act=active_type)
  23 
  24 
  25 def shortcut(input, ch_in, ch_out, stride):
  26     if ch_in != ch_out:
  27         return conv_bn_layer(input, ch_out, 1, stride, 0,
  28                              paddle.activation.Linear())
  29     else:
  30         return input
  31 
  32 
  33 def basicblock(input, ch_in, ch_out, stride):
  34     short = shortcut(input, ch_in, ch_out, stride)
  35     conv1 = conv_bn_layer(input, ch_out, 3, stride, 1)
  36     conv2 = conv_bn_layer(conv1, ch_out, 3, 1, 1, paddle.activation.Linear())
  37     return paddle.layer.addto(
  38         input=[short, conv2], act=paddle.activation.Relu())
  39 
  40 
  41 def bottleneck(input, ch_in, ch_out, stride):
  42     short = shortcut(input, ch_in, ch_out * 4, stride)
  43     conv1 = conv_bn_layer(input, ch_out, 1, stride, 0)
  44     conv2 = conv_bn_layer(conv1, ch_out, 3, 1, 1)
  45     conv3 = conv_bn_layer(conv2, ch_out * 4, 1, 1, 0,
  46                           paddle.activation.Linear())
  47     return paddle.layer.addto(
  48         input=[short, conv3], act=paddle.activation.Relu())
  49 
  50 
  51 def layer_warp(block_func, input, ch_in, ch_out, count, stride):
  52     conv = block_func(input, ch_in, ch_out, stride)
  53     for i in range(1, count):
  54         conv = block_func(conv, ch_out, ch_out, 1)
  55     return conv
  56 
  57 
  58 def resnet_imagenet(input, class_dim, depth=50):
  59     cfg = {
  60         18: ([2, 2, 2, 1], basicblock),
  61         34: ([3, 4, 6, 3], basicblock),
  62         50: ([3, 4, 6, 3], bottleneck),
  63         101: ([3, 4, 23, 3], bottleneck),
  64         152: ([3, 8, 36, 3], bottleneck)
  65     }
  66     stages, block_func = cfg[depth]
  67     conv1 = conv_bn_layer(
  68         input, ch_in=3, ch_out=64, filter_size=7, stride=2, padding=3)
  69     pool1 = paddle.layer.img_pool(input=conv1, pool_size=3, stride=2)
  70     res1 = layer_warp(block_func, pool1, 64, 64, stages[0], 1)
  71     res2 = layer_warp(block_func, res1, 64, 128, stages[1], 2)
  72     res3 = layer_warp(block_func, res2, 128, 256, stages[2], 2)
  73     res4 = layer_warp(block_func, res3, 256, 512, stages[3], 2)
  74     pool2 = paddle.layer.img_pool(
  75         input=res4, pool_size=7, stride=1, pool_type=paddle.pooling.Avg())
  76     out = paddle.layer.fc(
  77         input=pool2, size=class_dim, act=paddle.activation.Softmax())
  78     return out
  79 
  80 
  81 def resnet_cifar10(input, class_dim, depth=32):
  82     # depth should be one of 20, 32, 44, 56, 110, 1202
  83     assert (depth - 2) % 6 == 0
  84     n = (depth - 2) / 6
  85     nStages = {16, 64, 128}
  86     conv1 = conv_bn_layer(
  87         input, ch_in=3, ch_out=16, filter_size=3, stride=1, padding=1)
  88     res1 = layer_warp(basicblock, conv1, 16, 16, n, 1)
  89     res2 = layer_warp(basicblock, res1, 16, 32, n, 2)
  90     res3 = layer_warp(basicblock, res2, 32, 64, n, 2)
  91     pool = paddle.layer.img_pool(
  92         input=res3, pool_size=8, stride=1, pool_type=paddle.pooling.Avg())
  93     out = paddle.layer.fc(
  94         input=pool, size=class_dim, act=paddle.activation.Softmax())
  95     return out
  96
  [end of image_classification/resnet.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/image_classification/resnet.py b/image_classification/resnet.py
  --- a/image_classification/resnet.py
  +++ b/image_classification/resnet.py
  @@ -22,24 +22,24 @@
       return paddle.layer.batch_norm(input=tmp, act=active_type)
   
   
  -def shortcut(input, ch_in, ch_out, stride):
  -    if ch_in != ch_out:
  +def shortcut(input, ch_out, stride):
  +    if input.num_filters != ch_out:
           return conv_bn_layer(input, ch_out, 1, stride, 0,
                                paddle.activation.Linear())
       else:
           return input
   
   
  -def basicblock(input, ch_in, ch_out, stride):
  -    short = shortcut(input, ch_in, ch_out, stride)
  +def basicblock(input, ch_out, stride):
  +    short = shortcut(input, ch_out, stride)
       conv1 = conv_bn_layer(input, ch_out, 3, stride, 1)
       conv2 = conv_bn_layer(conv1, ch_out, 3, 1, 1, paddle.activation.Linear())
       return paddle.layer.addto(
           input=[short, conv2], act=paddle.activation.Relu())
   
   
  -def bottleneck(input, ch_in, ch_out, stride):
  -    short = shortcut(input, ch_in, ch_out * 4, stride)
  +def bottleneck(input, ch_out, stride):
  +    short = shortcut(input, ch_out * 4, stride)
       conv1 = conv_bn_layer(input, ch_out, 1, stride, 0)
       conv2 = conv_bn_layer(conv1, ch_out, 3, 1, 1)
       conv3 = conv_bn_layer(conv2, ch_out * 4, 1, 1, 0,
  @@ -48,10 +48,10 @@
           input=[short, conv3], act=paddle.activation.Relu())
   
   
  -def layer_warp(block_func, input, ch_in, ch_out, count, stride):
  -    conv = block_func(input, ch_in, ch_out, stride)
  +def layer_warp(block_func, input, ch_out, count, stride):
  +    conv = block_func(input, ch_out, stride)
       for i in range(1, count):
  -        conv = block_func(conv, ch_out, ch_out, 1)
  +        conv = block_func(conv, ch_out, 1)
       return conv
   
   
  @@ -67,10 +67,10 @@
       conv1 = conv_bn_layer(
           input, ch_in=3, ch_out=64, filter_size=7, stride=2, padding=3)
       pool1 = paddle.layer.img_pool(input=conv1, pool_size=3, stride=2)
  -    res1 = layer_warp(block_func, pool1, 64, 64, stages[0], 1)
  -    res2 = layer_warp(block_func, res1, 64, 128, stages[1], 2)
  -    res3 = layer_warp(block_func, res2, 128, 256, stages[2], 2)
  -    res4 = layer_warp(block_func, res3, 256, 512, stages[3], 2)
  +    res1 = layer_warp(block_func, pool1, 64, stages[0], 1)
  +    res2 = layer_warp(block_func, res1, 128, stages[1], 2)
  +    res3 = layer_warp(block_func, res2, 256, stages[2], 2)
  +    res4 = layer_warp(block_func, res3, 512, stages[3], 2)
       pool2 = paddle.layer.img_pool(
           input=res4, pool_size=7, stride=1, pool_type=paddle.pooling.Avg())
       out = paddle.layer.fc(
  
verification_info: {"golden_diff": "diff --git a/image_classification/resnet.py b/image_classification/resnet.py\n--- a/image_classification/resnet.py\n+++ b/image_classification/resnet.py\n@@ -22,24 +22,24 @@\n     return paddle.layer.batch_norm(input=tmp, act=active_type)\n \n \n-def shortcut(input, ch_in, ch_out, stride):\n-    if ch_in != ch_out:\n+def shortcut(input, ch_out, stride):\n+    if input.num_filters != ch_out:\n         return conv_bn_layer(input, ch_out, 1, stride, 0,\n                              paddle.activation.Linear())\n     else:\n         return input\n \n \n-def basicblock(input, ch_in, ch_out, stride):\n-    short = shortcut(input, ch_in, ch_out, stride)\n+def basicblock(input, ch_out, stride):\n+    short = shortcut(input, ch_out, stride)\n     conv1 = conv_bn_layer(input, ch_out, 3, stride, 1)\n     conv2 = conv_bn_layer(conv1, ch_out, 3, 1, 1, paddle.activation.Linear())\n     return paddle.layer.addto(\n         input=[short, conv2], act=paddle.activation.Relu())\n \n \n-def bottleneck(input, ch_in, ch_out, stride):\n-    short = shortcut(input, ch_in, ch_out * 4, stride)\n+def bottleneck(input, ch_out, stride):\n+    short = shortcut(input, ch_out * 4, stride)\n     conv1 = conv_bn_layer(input, ch_out, 1, stride, 0)\n     conv2 = conv_bn_layer(conv1, ch_out, 3, 1, 1)\n     conv3 = conv_bn_layer(conv2, ch_out * 4, 1, 1, 0,\n@@ -48,10 +48,10 @@\n         input=[short, conv3], act=paddle.activation.Relu())\n \n \n-def layer_warp(block_func, input, ch_in, ch_out, count, stride):\n-    conv = block_func(input, ch_in, ch_out, stride)\n+def layer_warp(block_func, input, ch_out, count, stride):\n+    conv = block_func(input, ch_out, stride)\n     for i in range(1, count):\n-        conv = block_func(conv, ch_out, ch_out, 1)\n+        conv = block_func(conv, ch_out, 1)\n     return conv\n \n \n@@ -67,10 +67,10 @@\n     conv1 = conv_bn_layer(\n         input, ch_in=3, ch_out=64, filter_size=7, stride=2, padding=3)\n     pool1 = paddle.layer.img_pool(input=conv1, pool_size=3, stride=2)\n-    res1 = layer_warp(block_func, pool1, 64, 64, stages[0], 1)\n-    res2 = layer_warp(block_func, res1, 64, 128, stages[1], 2)\n-    res3 = layer_warp(block_func, res2, 128, 256, stages[2], 2)\n-    res4 = layer_warp(block_func, res3, 256, 512, stages[3], 2)\n+    res1 = layer_warp(block_func, pool1, 64, stages[0], 1)\n+    res2 = layer_warp(block_func, res1, 128, stages[1], 2)\n+    res3 = layer_warp(block_func, res2, 256, stages[2], 2)\n+    res4 = layer_warp(block_func, res3, 512, stages[3], 2)\n     pool2 = paddle.layer.img_pool(\n         input=res4, pool_size=7, stride=1, pool_type=paddle.pooling.Avg())\n     out = paddle.layer.fc(\n", "issue": "resnet\u6a21\u578b\u914d\u7f6e\u7684\u95ee\u9898\n\u76ee\u524dresnet\u7684\u914d\u7f6e\u6709\u4e00\u4e9b\u95ee\u9898\uff0c\u53ef\u89c1 https://github.com/PaddlePaddle/models/issues/308#issuecomment-331384031\n", "before_files": [{"content": "import paddle.v2 as paddle\n\n__all__ = ['resnet_imagenet', 'resnet_cifar10']\n\n\ndef conv_bn_layer(input,\n                  ch_out,\n                  filter_size,\n                  stride,\n                  padding,\n                  active_type=paddle.activation.Relu(),\n                  ch_in=None):\n    tmp = paddle.layer.img_conv(\n        input=input,\n        filter_size=filter_size,\n        num_channels=ch_in,\n        num_filters=ch_out,\n        stride=stride,\n        padding=padding,\n        act=paddle.activation.Linear(),\n        bias_attr=False)\n    return paddle.layer.batch_norm(input=tmp, act=active_type)\n\n\ndef shortcut(input, ch_in, ch_out, stride):\n    if ch_in != ch_out:\n        return conv_bn_layer(input, ch_out, 1, stride, 0,\n                             paddle.activation.Linear())\n    else:\n        return input\n\n\ndef basicblock(input, ch_in, ch_out, stride):\n    short = shortcut(input, ch_in, ch_out, stride)\n    conv1 = conv_bn_layer(input, ch_out, 3, stride, 1)\n    conv2 = conv_bn_layer(conv1, ch_out, 3, 1, 1, paddle.activation.Linear())\n    return paddle.layer.addto(\n        input=[short, conv2], act=paddle.activation.Relu())\n\n\ndef bottleneck(input, ch_in, ch_out, stride):\n    short = shortcut(input, ch_in, ch_out * 4, stride)\n    conv1 = conv_bn_layer(input, ch_out, 1, stride, 0)\n    conv2 = conv_bn_layer(conv1, ch_out, 3, 1, 1)\n    conv3 = conv_bn_layer(conv2, ch_out * 4, 1, 1, 0,\n                          paddle.activation.Linear())\n    return paddle.layer.addto(\n        input=[short, conv3], act=paddle.activation.Relu())\n\n\ndef layer_warp(block_func, input, ch_in, ch_out, count, stride):\n    conv = block_func(input, ch_in, ch_out, stride)\n    for i in range(1, count):\n        conv = block_func(conv, ch_out, ch_out, 1)\n    return conv\n\n\ndef resnet_imagenet(input, class_dim, depth=50):\n    cfg = {\n        18: ([2, 2, 2, 1], basicblock),\n        34: ([3, 4, 6, 3], basicblock),\n        50: ([3, 4, 6, 3], bottleneck),\n        101: ([3, 4, 23, 3], bottleneck),\n        152: ([3, 8, 36, 3], bottleneck)\n    }\n    stages, block_func = cfg[depth]\n    conv1 = conv_bn_layer(\n        input, ch_in=3, ch_out=64, filter_size=7, stride=2, padding=3)\n    pool1 = paddle.layer.img_pool(input=conv1, pool_size=3, stride=2)\n    res1 = layer_warp(block_func, pool1, 64, 64, stages[0], 1)\n    res2 = layer_warp(block_func, res1, 64, 128, stages[1], 2)\n    res3 = layer_warp(block_func, res2, 128, 256, stages[2], 2)\n    res4 = layer_warp(block_func, res3, 256, 512, stages[3], 2)\n    pool2 = paddle.layer.img_pool(\n        input=res4, pool_size=7, stride=1, pool_type=paddle.pooling.Avg())\n    out = paddle.layer.fc(\n        input=pool2, size=class_dim, act=paddle.activation.Softmax())\n    return out\n\n\ndef resnet_cifar10(input, class_dim, depth=32):\n    # depth should be one of 20, 32, 44, 56, 110, 1202\n    assert (depth - 2) % 6 == 0\n    n = (depth - 2) / 6\n    nStages = {16, 64, 128}\n    conv1 = conv_bn_layer(\n        input, ch_in=3, ch_out=16, filter_size=3, stride=1, padding=1)\n    res1 = layer_warp(basicblock, conv1, 16, 16, n, 1)\n    res2 = layer_warp(basicblock, res1, 16, 32, n, 2)\n    res3 = layer_warp(basicblock, res2, 32, 64, n, 2)\n    pool = paddle.layer.img_pool(\n        input=res3, pool_size=8, stride=1, pool_type=paddle.pooling.Avg())\n    out = paddle.layer.fc(\n        input=pool, size=class_dim, act=paddle.activation.Softmax())\n    return out\n", "path": "image_classification/resnet.py"}]}