In [1]:
import caffe
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

In [2]:
net = caffe.Net('deploy.prototxt',caffe.TEST)

In [25]:
# net.layers[0].blobs>0

for i ,(name,layer) in enumerate(zip(net._layer_names,net.layers)):
    
#     display all layers
    print(name)
    for bottom_name in net.bottom_names[name]:
        
        print('layer_%s bottom name: '%name,bottom_name)
    if(len(net.bottom_names[name])>1):
        print('True')
#     parameters layers
#     if(len(layer.blobs)>0):
#         print(name)


data
conv1
('layer_conv1 bottom name: ', 'data')
relu1
('layer_relu1 bottom name: ', 'conv1')
norm1
('layer_norm1 bottom name: ', 'conv1')
pool1
('layer_pool1 bottom name: ', 'norm1')
conv2
('layer_conv2 bottom name: ', 'pool1')
relu2
('layer_relu2 bottom name: ', 'conv2')
norm2
('layer_norm2 bottom name: ', 'conv2')
pool2
('layer_pool2 bottom name: ', 'norm2')
conv3
('layer_conv3 bottom name: ', 'pool2')
relu3
('layer_relu3 bottom name: ', 'conv3')
conv4
('layer_conv4 bottom name: ', 'conv3')
relu4
('layer_relu4 bottom name: ', 'conv4')
conv5
('layer_conv5 bottom name: ', 'conv4')
relu5
('layer_relu5 bottom name: ', 'conv5')
pool5
('layer_pool5 bottom name: ', 'conv5')
fc6
('layer_fc6 bottom name: ', 'pool5')
relu6
('layer_relu6 bottom name: ', 'fc6')
drop6
('layer_drop6 bottom name: ', 'fc6')
fc7
('layer_fc7 bottom name: ', 'fc6')
relu7
('layer_relu7 bottom name: ', 'fc7')
drop7
('layer_drop7 bottom name: ', 'fc7')
fc8
('layer_fc8 bottom name: ', 'fc7')
prob
('layer_prob bottom name: ', 'fc8')

In [3]:
arr = np.array([[1,2,3],[2,3,4]])
arr.swapaxes(0,1)


Out[3]:
array([[1, 2],
       [2, 3],
       [3, 4]])

In [4]:
arr2 = np.array([[2,6,7],[8,9,5]])
np.concatenate([arr,arr2],axis=1)


Out[4]:
array([[1, 2, 3, 2, 6, 7],
       [2, 3, 4, 8, 9, 5]])

In [5]:
# np.concatenate([[[1,2]],[[2,3]],[[3,3]]],axis=1)
print(arr2[:])
print(arr2[None])
print(arr2[:,None])
print(arr2[:,:,None])


[[2 6 7]
 [8 9 5]]
[[[2 6 7]
  [8 9 5]]]
[[[2 6 7]]

 [[8 9 5]]]
[[[2]
  [6]
  [7]]

 [[8]
  [9]
  [5]]]

In [11]:
def transform(D,W):
    W, D = np.concatenate([w[:,None] for w in W], axis=1), np.concatenate([d[:,:,None] for d in D], axis=2)
    return W.reshape((-1,)+W.shape[2:]), D.reshape((D.shape[0], -1)+D.shape[3:])


Out[11]:
()