name: '2dUnet'
force_backward: true
layer { top: 'data' top: 'label' name: 'loaddata' type: 'HDF5Data' hdf5_data_param { source: 'trainfileList.txt' batch_size: 1 } include: { phase: TRAIN }}
layer { bottom: 'data' top: 'd0b' name: 'conv_d0a-b' type: 'Convolution' param {lr_mult: 1 decay_mult: 1} param {lr_mult: 2 decay_mult: 0} convolution_param { num_output: 64 pad: 0 kernel_size: 3 engine: CAFFE weight_filler { type: 'xavier' }} }
layer { bottom: 'd0b' top: 'd0b' name: 'relu_d0b' type: 'ReLU' }
layer { bottom: 'd0b' top: 'd0c' name: 'conv_d0b-c' type: 'Convolution' param {lr_mult: 1 decay_mult: 1} param {lr_mult: 2 decay_mult: 0} convolution_param { num_output: 64 pad: 0 kernel_size: 3 engine: CAFFE weight_filler { type: 'xavier' }} }
layer { bottom: 'd0c' top: 'd0c' name: 'relu_d0c' type: 'ReLU' }
layer { bottom: 'd0c' top: 'd1a' name: 'pool_d0c-1a' type: 'Pooling' pooling_param { pool: MAX kernel_size: 2 stride: 2 } }
layer { bottom: 'd1a' top: 'd1b' name: 'conv_d1a-b' type: 'Convolution' param {lr_mult: 1 decay_mult: 1} param {lr_mult: 2 decay_mult: 0} convolution_param { num_output: 128 pad: 0 kernel_size: 3 engine: CAFFE weight_filler { type: 'xavier' }} }
layer { bottom: 'd1b' top: 'd1b' name: 'relu_d1b' type: 'ReLU' }
layer { bottom: 'd1b' top: 'd1c' name: 'conv_d1b-c' type: 'Convolution' param {lr_mult: 1 decay_mult: 1} param {lr_mult: 2 decay_mult: 0} convolution_param { num_output: 128 pad: 0 kernel_size: 3 engine: CAFFE weight_filler { type: 'xavier' }} }
layer { bottom: 'd1c' top: 'd1c' name: 'relu_d1c' type: 'ReLU' }
layer { bottom: 'd1c' top: 'd2a' name: 'pool_d1c-2a' type: 'Pooling' pooling_param { pool: MAX kernel_size: 2 stride: 2 } }
layer { bottom: 'd2a' top: 'd2b' name: 'conv_d2a-b' type: 'Convolution' param {lr_mult: 1 decay_mult: 1} param {lr_mult: 2 decay_mult: 0} convolution_param { num_output: 256 pad: 0 kernel_size: 3 engine: CAFFE weight_filler { type: 'xavier' }} }
layer { bottom: 'd2b' top: 'd2b' name: 'relu_d2b' type: 'ReLU' }
layer { bottom: 'd2b' top: 'd2c' name: 'conv_d2b-c' type: 'Convolution' param {lr_mult: 1 decay_mult: 1} param {lr_mult: 2 decay_mult: 0} convolution_param { num_output: 256 pad: 0 kernel_size: 3 engine: CAFFE weight_filler { type: 'xavier' }} }
layer { bottom: 'd2c' top: 'd2c' name: 'relu_d2c' type: 'ReLU' }
layer { bottom: 'd2c' top: 'd3a' name: 'pool_d2c-3a' type: 'Pooling' pooling_param { pool: MAX kernel_size: 2 stride: 2 } }
layer { bottom: 'd3a' top: 'd3b' name: 'conv_d3a-b' type: 'Convolution' param {lr_mult: 1 decay_mult: 1} param {lr_mult: 2 decay_mult: 0} convolution_param { num_output: 512 pad: 0 kernel_size: 3 engine: CAFFE weight_filler { type: 'xavier' }} }
layer { bottom: 'd3b' top: 'd3b' name: 'relu_d3b' type: 'ReLU' }
layer { bottom: 'd3b' top: 'd3c' name: 'conv_d3b-c' type: 'Convolution' param {lr_mult: 1 decay_mult: 1} param {lr_mult: 2 decay_mult: 0} convolution_param { num_output: 512 pad: 0 kernel_size: 3 engine: CAFFE weight_filler { type: 'xavier' }} }
layer { bottom: 'd3c' top: 'd3c' name: 'relu_d3c' type: 'ReLU' }
layer { bottom: 'd3c' top: 'd3c' name: 'dropout_d3c' type: 'Dropout' dropout_param { dropout_ratio: 0.5 } include: { phase: TRAIN }}
layer { bottom: 'd3c' top: 'd4a' name: 'pool_d3c-4a' type: 'Pooling' pooling_param { pool: MAX kernel_size: 2 stride: 2 } }
layer { bottom: 'd4a' top: 'd4b' name: 'conv_d4a-b' type: 'Convolution' param {lr_mult: 1 decay_mult: 1} param {lr_mult: 2 decay_mult: 0} convolution_param { num_output: 1024 pad: 0 kernel_size: 3 engine: CAFFE weight_filler { type: 'xavier' }} }
layer { bottom: 'd4b' top: 'd4b' name: 'relu_d4b' type: 'ReLU' }
layer { bottom: 'd4b' top: 'd4c' name: 'conv_d4b-c' type: 'Convolution' param {lr_mult: 1 decay_mult: 1} param {lr_mult: 2 decay_mult: 0} convolution_param { num_output: 1024 pad: 0 kernel_size: 3 engine: CAFFE weight_filler { type: 'xavier' }} }
layer { bottom: 'd4c' top: 'd4c' name: 'relu_d4c' type: 'ReLU' }
layer { bottom: 'd4c' top: 'd4c' name: 'dropout_d4c' type: 'Dropout' dropout_param { dropout_ratio: 0.5 } include: { phase: TRAIN }}
layer { bottom: 'd4c' top: 'u3a' name: 'upconv_d4c_u3a' type: 'Deconvolution' param {lr_mult: 1 decay_mult: 1} param {lr_mult: 2 decay_mult: 0} convolution_param { num_output: 512 pad: 0 kernel_size: 2 stride: 2 weight_filler { type: 'xavier' }} }
layer { bottom: 'u3a' top: 'u3a' name: 'relu_u3a' type: 'ReLU' }
layer { bottom: 'd3c' bottom: 'u3a' top: 'd3cc' name: 'crop_d3c-d3cc' type: 'Crop' }
layer { bottom: 'u3a' bottom: 'd3cc' top: 'u3b' name: 'concat_d3cc_u3a-b' type: 'Concat' }
layer { bottom: 'u3b' top: 'u3c' name: 'conv_u3b-c' type: 'Convolution' param {lr_mult: 1 decay_mult: 1} param {lr_mult: 2 decay_mult: 0} convolution_param { num_output: 512 pad: 0 kernel_size: 3 engine: CAFFE weight_filler { type: 'xavier' }} }
layer { bottom: 'u3c' top: 'u3c' name: 'relu_u3c' type: 'ReLU' }
layer { bottom: 'u3c' top: 'u3d' name: 'conv_u3c-d' type: 'Convolution' param {lr_mult: 1 decay_mult: 1} param {lr_mult: 2 decay_mult: 0} convolution_param { num_output: 512 pad: 0 kernel_size: 3 engine: CAFFE weight_filler { type: 'xavier' }} }
layer { bottom: 'u3d' top: 'u3d' name: 'relu_u3d' type: 'ReLU' }
layer { bottom: 'u3d' top: 'u2a' name: 'upconv_u3d_u2a' type: 'Deconvolution' param {lr_mult: 1 decay_mult: 1} param {lr_mult: 2 decay_mult: 0} convolution_param { num_output: 256 pad: 0 kernel_size: 2 stride: 2 weight_filler { type: 'xavier' }} }
layer { bottom: 'u2a' top: 'u2a' name: 'relu_u2a' type: 'ReLU' }
layer { bottom: 'd2c' bottom: 'u2a' top: 'd2cc' name: 'crop_d2c-d2cc' type: 'Crop' }
layer { bottom: 'u2a' bottom: 'd2cc' top: 'u2b' name: 'concat_d2cc_u2a-b' type: 'Concat' }
layer { bottom: 'u2b' top: 'u2c' name: 'conv_u2b-c' type: 'Convolution' param {lr_mult: 1 decay_mult: 1} param {lr_mult: 2 decay_mult: 0} convolution_param { num_output: 256 pad: 0 kernel_size: 3 engine: CAFFE weight_filler { type: 'xavier' }} }
layer { bottom: 'u2c' top: 'u2c' name: 'relu_u2c' type: 'ReLU' }
layer { bottom: 'u2c' top: 'u2d' name: 'conv_u2c-d' type: 'Convolution' param {lr_mult: 1 decay_mult: 1} param {lr_mult: 2 decay_mult: 0} convolution_param { num_output: 256 pad: 0 kernel_size: 3 engine: CAFFE weight_filler { type: 'xavier' }} }
layer { bottom: 'u2d' top: 'u2d' name: 'relu_u2d' type: 'ReLU' }
layer { bottom: 'u2d' top: 'u1a' name: 'upconv_u2d_u1a' type: 'Deconvolution' param {lr_mult: 1 decay_mult: 1} param {lr_mult: 2 decay_mult: 0} convolution_param { num_output: 128 pad: 0 kernel_size: 2 stride: 2 weight_filler { type: 'xavier' }} }
layer { bottom: 'u1a' top: 'u1a' name: 'relu_u1a' type: 'ReLU' }
layer { bottom: 'd1c' bottom: 'u1a' top: 'd1cc' name: 'crop_d1c-d1cc' type: 'Crop' }
layer { bottom: 'u1a' bottom: 'd1cc' top: 'u1b' name: 'concat_d1cc_u1a-b' type: 'Concat' }
layer { bottom: 'u1b' top: 'u1c' name: 'conv_u1b-c' type: 'Convolution' param {lr_mult: 1 decay_mult: 1} param {lr_mult: 2 decay_mult: 0} convolution_param { num_output: 128 pad: 0 kernel_size: 3 engine: CAFFE weight_filler { type: 'xavier' }} }
layer { bottom: 'u1c' top: 'u1c' name: 'relu_u1c' type: 'ReLU' }
layer { bottom: 'u1c' top: 'u1d' name: 'conv_u1c-d' type: 'Convolution' param {lr_mult: 1 decay_mult: 1} param {lr_mult: 2 decay_mult: 0} convolution_param { num_output: 128 pad: 0 kernel_size: 3 engine: CAFFE weight_filler { type: 'xavier' }} }
layer { bottom: 'u1d' top: 'u1d' name: 'relu_u1d' type: 'ReLU' }
layer { bottom: 'u1d' top: 'u0a' name: 'upconv_u1d_u0a' type: 'Deconvolution' param {lr_mult: 1 decay_mult: 1} param {lr_mult: 2 decay_mult: 0} convolution_param { num_output: 128 pad: 0 kernel_size: 2 stride: 2 weight_filler { type: 'xavier' }} }
layer { bottom: 'u0a' top: 'u0a' name: 'relu_u0a' type: 'ReLU' }
layer { bottom: 'd0c' bottom: 'u0a' top: 'd0cc' name: 'crop_d0c-d0cc' type: 'Crop' }
layer { bottom: 'u0a' bottom: 'd0cc' top: 'u0b' name: 'concat_d0cc_u0a-b' type: 'Concat' }
layer { bottom: 'u0b' top: 'u0c' name: 'conv_u0b-c' type: 'Convolution' param {lr_mult: 1 decay_mult: 1} param {lr_mult: 2 decay_mult: 0} convolution_param { num_output: 64 pad: 0 kernel_size: 3 engine: CAFFE weight_filler { type: 'xavier' }} }
layer { bottom: 'u0c' top: 'u0c' name: 'relu_u0c' type: 'ReLU' }
layer { bottom: 'u0c' top: 'u0d' name: 'conv_u0c-d' type: 'Convolution' param {lr_mult: 1 decay_mult: 1} param {lr_mult: 2 decay_mult: 0} convolution_param { num_output: 64 pad: 0 kernel_size: 3 engine: CAFFE weight_filler { type: 'xavier' }} }
layer { bottom: 'u0d' top: 'u0d' name: 'relu_u0d' type: 'ReLU' }
layer { bottom: 'u0d' top: 'score' name: 'conv_u0d-score' type: 'Convolution' param {lr_mult: 1 decay_mult: 1} param {lr_mult: 2 decay_mult: 0} convolution_param { engine: CAFFE num_output: 2 pad: 0 kernel_size: 1 weight_filler { type: 'xavier' }} }
layer { bottom: 'score' bottom: 'label' top: 'loss' name: 'loss' type: 'SoftmaxWithLoss' loss_param { ignore_label: 2 } include: { phase: TRAIN }}
train_dir = 'train/'
data_dir = 'data/'
label_dir = 'label/'
f = h5py.File('train_430_rgm.h5', 'w')
f.create_dataset('data', (85*3, 1, 430, 430), dtype='f8')
f.create_dataset('label', (85*3, 1, 260, 260), dtype='f8')
def gland(x):
return (0.0 if x == 0 else 1.0)
vgland = np.vectorize(gland)
i = 0
for filename in os.listdir(train_dir+data_dir):
data = misc.imread(train_dir+data_dir+filename, flatten=True)
img = data.astype(float) / 255
img = img[0:430,0:430]
f['data'][i] = img.transpose()
f['data'][i+1] = np.fliplr(img.transpose())
f['data'][i+2] = np.flipud(img.transpose())
i+=3
i = 0
for filename in os.listdir(train_dir+label_dir):
img = misc.imread(train_dir+label_dir+filename)
img = img[85:345,85:345]
f['label'][i] = vgland(img.transpose())
f['label'][i+1] = vgland(np.fliplr(img.transpose()))
f['label'][i+2] = vgland(np.flipud(img.transpose()))
i+=3
f.close()
up
--
You received this message because you are subscribed to the Google Groups "Caffe Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to caffe-users+unsubscribe@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/caffe-users/da14957a-0a99-40e7-9251-b241c64972d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
layer {
name: "upscale_4"
type: "Deconvolution"
bottom: "encode_2"
top: "upscale_4"
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 512
bias_term: false
kernel_size: 2
group: 512
stride: 2
weight_filler {
type: "constant"
value: 1
}
}
}
To unsubscribe from this group and stop receiving emails from it, send an email to caffe-users...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to caffe-users...@googlegroups.com.
out = solver.net.blobs['name of the layer'].data[0].argmax(0)
img = np.array(out).astype(np.uint8) #obtaining the numpy array in python for visualizing image
img = img > 0
img = img * 255
cv2.imwrite("name.png", img) # save image in a directory
Now, also you can obtaining the weights of these intermediate layers,
it is good because you know if your network is learning, i.e you can see if the weights are not zero. The
way to know this is doing:
weights = solver.net.blobs['name layer'].data[0]
print 'name layer'
print np.unique(weights)Remenber before doing all this you have that load you .caffemodel, i.e you can doing you script.py in the case of pycaffe. For instance:import sys
import numpy as np
import os
from PIL import Image
import setproctitle
v=setproctitle.setproctitle(os.path.basename(os.getcwd()))
weights = 'path/weights.caffemodel'
print weightsweights = 'path/weights.caffemodel'
caffe.set_mode_cpu()
solver = caffe.SGDSolver('solver.prototxt')
solver.net.copy_from(weights)val = np.loadtxt('path/namesvalid.txt', dtype=str)
DEBUG_WEIGHTS = 1if DEBUG_WEIGHTS:
solver.step(1)weights = solver.net.blobs['name layer'].data[0]
print 'name layer'
print np.unique(weights)out = solver.net.blobs['name of the layer'].data[0].argmax(0)
img = np.array(out).astype(np.uint8) #obtaining thne numpy array in python for visualizing image
img = img > 0
img = img * 255
cv2.imwrite("name.png", img) # save image in the directpryI hope that it help you!!!!
To unsubscribe from this group and stop receiving emails from it, send an email to caffe-users+unsubscribe@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/caffe-users/dcfa27d3-cc30-4211-bd70-1f7955d409fb%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to caffe-users+unsubscribe@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/caffe-users/54a1d6f7-0c15-439e-9ddb-a32a26137013%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to caffe-users+unsubscribe@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/caffe-users/7b30139b-35e9-4e7f-87b6-c7263ebd0213%40googlegroups.com.