L.Tile layer in Caffe

Posted 机器学习的小学生

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了L.Tile layer in Caffe相关的知识,希望对你有一定的参考价值。

test_tile_layer.py

#coding=gbk
import numpy as np

import caffe
# weight_file can be any prtrained models
weight_file = '../attention_network/snapshots_aflw_vgg16_klLoss_finetune_attention1/cross1/vgg_iter_10000.caffemodel'
deploy_file = 'deploy.prototxt'
net = caffe.Net(deploy_file,weight_file,caffe.TEST)  

arr0 = np.array([[11,12,13],[21,22,23]]) # w11 w12 w13 for sample1, w21 w22 w23 for sample2
print(arr0.shape) # (2,3),2 stand for sample, 3 stand for channel
print(arr0)

arr = np.reshape(arr0,(arr0.shape[0],arr0.shape[1],1,1))

net.blobs['Features'].data[...] = arr 

net.forward()

feat = net.blobs['Features'].data

tile1 = net.blobs['tile1'].data

tile2 = net.blobs['tile2'].data

print('feat: ',feat.shape)
print('tile1: ',tile1.shape)
print('tile2: ',tile2.shape)

# check values, check tiles

print(tile2[0,0,:,:]) # all same values with arr0[0,0]

deploy.prototxt


layer 
  name: "data"
  type: "Input"
  top: "Features"
  input_param 
    shape 
      dim: 2
      dim: 3
 	  dim: 1
 	  dim: 1
    
  


layer 
  name: "tile1"
  type: "Tile"
  bottom: "Features"
  top: "tile1"
  tile_param 
    axis: 2
    tiles: 2
  


layer 
  name: "tile1"
  type: "Tile"
  bottom: "tile1"
  top: "tile2"
  tile_param 
    axis: 3
    tiles: 2
  

以上是关于L.Tile layer in Caffe的主要内容,如果未能解决你的问题,请参考以下文章

什么是Caffe?

smooth_L1_loss_layer.cu解读 caffe源码初认识

caffe新建layer完整流程;

在caffe中添加新的layer

Caffe : Layer Catalogue

如何给caffe添加新的layer ?