MCPcopy Create free account
hub / github.com/BVLC/caffe / coord_map

Function coord_map

python/caffe/coord_map.py:57–79  ·  view source on GitHub ↗

Define the coordinate mapping by its - axis - scale: output coord[i * scale] <- input_coord[i] - shift: output coord[i] <- output_coord[i + shift] s.t. the identity mapping, as for pointwise layers like ReLu, is defined by (None, 1, 0) since it is independent of axis and doe

(fn)

Source from the content-addressed store, hash-verified

55
56
57def coord_map(fn):
58 """
59 Define the coordinate mapping by its
60 - axis
61 - scale: output coord[i * scale] <- input_coord[i]
62 - shift: output coord[i] <- output_coord[i + shift]
63 s.t. the identity mapping, as for pointwise layers like ReLu, is defined by
64 (None, 1, 0) since it is independent of axis and does not transform coords.
65 """
66 if fn.type_name in ['Convolution', 'Pooling', 'Im2col']:
67 axis, stride, ks, pad = conv_params(fn)
68 return axis, 1 / stride, (pad - (ks - 1) / 2) / stride
69 elif fn.type_name == 'Deconvolution':
70 axis, stride, ks, pad = conv_params(fn)
71 return axis, stride, (ks - 1) / 2 - pad
72 elif fn.type_name in PASS_THROUGH_LAYERS:
73 return None, 1, 0
74 elif fn.type_name == 'Crop':
75 axis, offset = crop_params(fn)
76 axis -= 1 # -1 for last non-coordinate dim.
77 return axis, 1, - offset
78 else:
79 raise UndefinedMapException
80
81
82class AxisMismatchException(Exception):

Callers 1

coord_map_from_toFunction · 0.85

Calls 2

conv_paramsFunction · 0.85
crop_paramsFunction · 0.85

Tested by

no test coverage detected