def vgg_net(path, pool_method='max', border_mode='same'):
    matconvnet = scipy.io.loadmat(path)
    img_mean = matconvnet['meta'][0][0][1][0][0][0][0][0]
    vgg_layers = matconvnet['layers'][0]
    layers = []
    for layer in vgg_layers:
        layer = layer[0][0]
        layer_type = layer[1][0]
        if layer_type == 'conv':
            params = layer[2][0]
            weights = params[0]
            bias = params[1]
            weights = np.transpose(weights, (3, 2, 0, 1)).astype(dp.float_)
            bias = np.reshape(bias, (1, bias.size, 1, 1)).astype(dp.float_)
            layers.append(conv_layer(weights, bias, border_mode))
        elif layer_type == 'pool':
            layers.append(pool_layer(pool_method, border_mode))
        elif layer_type == 'relu':
            layers.append(dp.ReLU())
        elif layer_type == 'softmax':
            pass
        else:
            raise ValueError('invalid layer type: %s' % layer_type)
    return layers, img_mean
dataset/ETHPy150Open andersbll/neural_artistic_style/matconvnet.py/vgg_net/original