def conv_forward_strides(x, w, b, conv_param):
    (N, C, H, W) = x.shape
    (F, _, HH, WW) = w.shape
    (stride, pad) = (conv_param['stride'], conv_param['pad'])
    assert ((((W + (2 * pad)) - WW) % stride) == 0), 'width does not work'
    assert ((((H + (2 * pad)) - HH) % stride) == 0), 'height does not work'
    p = pad
    x_padded = np.pad(x, ((0, 0), (0, 0), (p, p), (p, p)), mode='constant')
    H += (2 * pad)
    W += (2 * pad)
    out_h = (((H - HH) / stride) + 1)
    out_w = (((W - WW) / stride) + 1)
    shape = (C, HH, WW, N, out_h, out_w)
    strides = ((H * W), W, 1, ((C * H) * W), (stride * W), stride)
    strides = (x.itemsize * np.array(strides))
    x_stride = np.lib.stride_tricks.as_strided(x_padded, shape=shape, strides=strides)
    x_cols = np.ascontiguousarray(x_stride)
    x_cols.shape = (((C * HH) * WW), ((N * out_h) * out_w))
    res = (w.reshape(F, (- 1)).dot(x_cols) + b.reshape((- 1), 1))
    res.shape = (F, N, out_h, out_w)
    out = res.transpose(1, 0, 2, 3)
    out = np.ascontiguousarray(out)
    cache = (x, w, b, conv_param, x_cols)
    return (out, cache)
def conv_forward_strides(x, w, b, conv_param):
    (N, C, H, W) = x.shape
    (F, _, HH, WW) = w.shape
    (stride, pad) = (conv_param['stride'], conv_param['pad'])
    assert ((((W + (2 * pad)) - WW) % stride) == 0), 'width does not work'
    assert ((((H + (2 * pad)) - HH) % stride) == 0), 'height does not work'
    p = pad
    x_padded = np.pad(x, ((0, 0), (0, 0), (p, p), (p, p)), mode='constant')
    H += (2 * pad)
    W += (2 * pad)
    out_h = (((H - HH) / stride) + 1)
    out_w = (((W - WW) / stride) + 1)
    shape = (C, HH, WW, N, out_h, out_w)
    strides = ((H * W), W, 1, ((C * H) * W), (stride * W), stride)
    strides = (x.itemsize * np.array(strides))
    x_stride = np.lib.stride_tricks.as_strided(x_padded, shape=shape, strides=strides)
    x_cols = np.ascontiguousarray(x_stride)
    x_cols.shape = (((C * HH) * WW), ((N * out_h) * out_w))
    res = (w.reshape(F, (- 1)).dot(x_cols) + b.reshape((- 1), 1))
    res.shape = (F, N, out_h, out_w)
    out = res.transpose(1, 0, 2, 3)
    out = np.ascontiguousarray(out)
    cache = (x, w, b, conv_param, x_cols)
    return (out, cache)