/usr/local/lib64/python3.6/site-packages/caffe2/python
NameSizeModeActions
docs/-0755rm
examples/-0755rm
fakelowp/-0755rm
helpers/-0755rm
ideep/-0755rm
layers/-0755rm
mint/-0755rm
mkl/-0755rm
modeling/-0755rm
models/-0755rm
onnx/-0755rm
operator_test/-0755rm
predictor/-0755rm
rnn/-0755rm
serialized_test/-0755rm
test/-0755rm
trt/-0755rm
__pycache__/-0755rm
allcompare_test.py22550644editdlrm
attention.py123590644editdlrm
benchmark_generator.py49120644editdlrm
binarysize.py55210644editdlrm
brew.py47620644editdlrm
brew_test.py117390644editdlrm
build.py1530644editdlrm
cached_reader.py43940644editdlrm
caffe2_pybind11_state.cpython-36m-x86_64-linux-gnu.so482997120755editdlrm
caffe2_pybind11_state_gpu.cpython-36m-x86_64-linux-gnu.so490481440755editdlrm
caffe_translator.py352270644editdlrm
caffe_translator_test.py35530644editdlrm
checkpoint.py321010644editdlrm
checkpoint_test.py134050644editdlrm
cnn.py76260644editdlrm
context.py28410644editdlrm
context_test.py17920644editdlrm
control.py193090644editdlrm
control_ops_grad.py288930644editdlrm
control_ops_grad_test.py17520644editdlrm
control_ops_util.py108630644editdlrm
control_test.py122760644editdlrm
convert.py550644editdlrm
convert_test.py2010644editdlrm
convnet_benchmarks.py205330644editdlrm
convnet_benchmarks_test.py8390644editdlrm
core.py1194000644editdlrm
core_gradients_test.py380220644editdlrm
core_test.py476830644editdlrm
crf.py132500644editdlrm
crf_predict.py11590644editdlrm
crf_viterbi_test.py16630644editdlrm
dataio.py235320644editdlrm
dataio_test.py175750644editdlrm
dataset.py128860644editdlrm
data_parallel_model.py831000644editdlrm
data_parallel_model_test.py561450644editdlrm
data_workers.py159410644editdlrm
data_workers_test.py65610644editdlrm
db_file_reader.py66080644editdlrm
db_test.py11100644editdlrm
device_checker.py51570644editdlrm
dyndep.py15330644editdlrm
embedding_generation_benchmark.py52560644editdlrm
experiment_util.py36250644editdlrm
extension_loader.py7440644editdlrm
fakefp16_transform_lib.py3220644editdlrm
filler_test.py7480644editdlrm
functional.py44150644editdlrm
functional_test.py42040644editdlrm
fused_8bit_rowwise_conversion_ops_test.py39450644editdlrm
gradient_checker.py153770644editdlrm
gradient_check_test.py207290644editdlrm
gru_cell.py51290644editdlrm
hip_test_util.py4050644editdlrm
hsm_util.py22590644editdlrm
hypothesis_test.py1057620644editdlrm
hypothesis_test_util.py268530644editdlrm
ideep_test_util.py9980644editdlrm
layers_test.py929310644editdlrm
layer_model_helper.py293400644editdlrm
layer_model_instantiator.py39350644editdlrm
layer_parameter_sharing_test.py91480644editdlrm
layer_test_util.py48750644editdlrm
lazy.py2770644editdlrm
lazy_dyndep.py25620644editdlrm
lazy_dyndep_test.py39140644editdlrm
lengths_reducer_fused_8bit_rowwise_ops_test.py75750644editdlrm
lengths_reducer_rowwise_8bit_ops_test.py57100644editdlrm
lstm_benchmark.py106490644editdlrm
memonger.py340410644editdlrm
memonger_test.py369100644editdlrm
mkl_test_util.py11420644editdlrm
model_device_test.py47770644editdlrm
model_helper.py234920644editdlrm
model_helper_test.py23360644editdlrm
modifier_context.py17720644editdlrm
muji.py81310644editdlrm
muji_test.py30580644editdlrm
net_builder.py276790644editdlrm
net_builder_test.py113820644editdlrm
net_drawer.py142640644editdlrm
net_printer.py127040644editdlrm
net_printer_test.py31900644editdlrm
nomnigraph.py42160644editdlrm
nomnigraph_test.py154270644editdlrm
nomnigraph_transformations.py37870644editdlrm
nomnigraph_transformations_test.py57670644editdlrm
normalizer.py14110644editdlrm
normalizer_context.py10070644editdlrm
normalizer_test.py4870644editdlrm
numa_benchmark.py22300644editdlrm
numa_test.py16630644editdlrm
observer_test.py53160644editdlrm
operator_fp_exceptions_test.py12480644editdlrm
optimizer.py788130644editdlrm
optimizer_context.py14620644editdlrm
optimizer_test.py307050644editdlrm
optimizer_test_util.py91870644editdlrm
parallelize_bmuf_distributed_test.py99080644editdlrm
parallel_workers.py76820644editdlrm
parallel_workers_test.py35010644editdlrm
pipeline.py172830644editdlrm
pipeline_test.py25420644editdlrm
predictor_constants.py1980644editdlrm
python_op_test.py91690644editdlrm
queue_util.py44590644editdlrm
record_queue.py44530644editdlrm
recurrent.py132970644editdlrm
regularizer.py211200644editdlrm
regularizer_context.py10130644editdlrm
regularizer_test.py102660644editdlrm
rnn_cell.py682330644editdlrm
schema.py456210644editdlrm
schema_test.py157540644editdlrm
scope.py36230644editdlrm
scope_test.py52490644editdlrm
session.py76420644editdlrm
session_test.py20780644editdlrm
sparse_to_dense_mask_test.py65650644editdlrm
sparse_to_dense_test.py35560644editdlrm
task.py242740644editdlrm
task_test.py8700644editdlrm
test_util.py35240644editdlrm
text_file_reader.py19900644editdlrm
timeout_guard.py40540644editdlrm
toy_regression_test.py28220644editdlrm
transformations.py18320644editdlrm
transformations_test.py119600644editdlrm
tt_core.py93490644editdlrm
tt_core_test.py25180644editdlrm
utils.py141810644editdlrm
utils_test.py13990644editdlrm
visualize.py63150644editdlrm
workspace.py252630644editdlrm
workspace_test.py348440644editdlrm
_import_c_extension.py22500644editdlrm
__init__.py39250644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/caffe2/python/visualize.py (6315B)
## @package visualize # Module caffe2.python.visualize """Functions that could be used to visualize Tensors. This is adapted from the old-time iceberk package that Yangqing wrote... Oh gold memories. Before decaf and caffe. Why iceberk? Because I was at Berkeley, bears are vegetarian, and iceberg lettuce has layers of leaves. (This joke is so lame.) """ import numpy as np from matplotlib import cm, pyplot def ChannelFirst(arr): """Convert a HWC array to CHW.""" ndim = arr.ndim return arr.swapaxes(ndim - 1, ndim - 2).swapaxes(ndim - 2, ndim - 3) def ChannelLast(arr): """Convert a CHW array to HWC.""" ndim = arr.ndim return arr.swapaxes(ndim - 3, ndim - 2).swapaxes(ndim - 2, ndim - 1) class PatchVisualizer(object): """PatchVisualizer visualizes patches. """ def __init__(self, gap=1): self.gap = gap def ShowSingle(self, patch, cmap=None): """Visualizes one single patch. The input patch could be a vector (in which case we try to infer the shape of the patch), a 2-D matrix, or a 3-D matrix whose 3rd dimension has 3 channels. """ if len(patch.shape) == 1: patch = patch.reshape(self.get_patch_shape(patch)) elif len(patch.shape) > 2 and patch.shape[2] != 3: raise ValueError("The input patch shape isn't correct.") # determine color if len(patch.shape) == 2 and cmap is None: cmap = cm.gray pyplot.imshow(patch, cmap=cmap) return patch def ShowMultiple(self, patches, ncols=None, cmap=None, bg_func=np.mean): """Visualize multiple patches. In the passed in patches matrix, each row is a patch, in the shape of either n*n, n*n*1 or n*n*3, either in a flattened format (so patches would be a 2-D array), or a multi-dimensional tensor. We will try our best to figure out automatically the patch size. """ num_patches = patches.shape[0] if ncols is None: ncols = int(np.ceil(np.sqrt(num_patches))) nrows = int(np.ceil(num_patches / float(ncols))) if len(patches.shape) == 2: patches = patches.reshape( (patches.shape[0], ) + self.get_patch_shape(patches[0]) ) patch_size_expand = np.array(patches.shape[1:3]) + self.gap image_size = patch_size_expand * np.array([nrows, ncols]) - self.gap if len(patches.shape) == 4: if patches.shape[3] == 1: # gray patches patches = patches.reshape(patches.shape[:-1]) image_shape = tuple(image_size) if cmap is None: cmap = cm.gray elif patches.shape[3] == 3: # color patches image_shape = tuple(image_size) + (3, ) else: raise ValueError("The input patch shape isn't expected.") else: image_shape = tuple(image_size) if cmap is None: cmap = cm.gray image = np.ones(image_shape) * bg_func(patches) for pid in range(num_patches): row = pid // ncols * patch_size_expand[0] col = pid % ncols * patch_size_expand[1] image[row:row+patches.shape[1], col:col+patches.shape[2]] = \ patches[pid] pyplot.imshow(image, cmap=cmap, interpolation='nearest') pyplot.axis('off') return image def ShowImages(self, patches, *args, **kwargs): """Similar to ShowMultiple, but always normalize the values between 0 and 1 for better visualization of image-type data. """ patches = patches - np.min(patches) patches /= np.max(patches) + np.finfo(np.float64).eps return self.ShowMultiple(patches, *args, **kwargs) def ShowChannels(self, patch, cmap=None, bg_func=np.mean): """ This function shows the channels of a patch. The incoming patch should have shape [w, h, num_channels], and each channel will be visualized as a separate gray patch. """ if len(patch.shape) != 3: raise ValueError("The input patch shape isn't correct.") patch_reordered = np.swapaxes(patch.T, 1, 2) return self.ShowMultiple(patch_reordered, cmap=cmap, bg_func=bg_func) def get_patch_shape(self, patch): """Gets the shape of a single patch. Basically it tries to interpret the patch as a square, and also check if it is in color (3 channels) """ edgeLen = np.sqrt(patch.size) if edgeLen != np.floor(edgeLen): # we are given color patches edgeLen = np.sqrt(patch.size / 3.) if edgeLen != np.floor(edgeLen): raise ValueError("I can't figure out the patch shape.") return (edgeLen, edgeLen, 3) else: edgeLen = int(edgeLen) return (edgeLen, edgeLen) _default_visualizer = PatchVisualizer() """Utility functions that directly point to functions in the default visualizer. These functions don't return anything, so you won't see annoying printouts of the visualized images. If you want to save the images for example, you should explicitly instantiate a patch visualizer, and call those functions. """ class NHWC(object): @staticmethod def ShowSingle(*args, **kwargs): _default_visualizer.ShowSingle(*args, **kwargs) @staticmethod def ShowMultiple(*args, **kwargs): _default_visualizer.ShowMultiple(*args, **kwargs) @staticmethod def ShowImages(*args, **kwargs): _default_visualizer.ShowImages(*args, **kwargs) @staticmethod def ShowChannels(*args, **kwargs): _default_visualizer.ShowChannels(*args, **kwargs) class NCHW(object): @staticmethod def ShowSingle(patch, *args, **kwargs): _default_visualizer.ShowSingle(ChannelLast(patch), *args, **kwargs) @staticmethod def ShowMultiple(patch, *args, **kwargs): _default_visualizer.ShowMultiple(ChannelLast(patch), *args, **kwargs) @staticmethod def ShowImages(patch, *args, **kwargs): _default_visualizer.ShowImages(ChannelLast(patch), *args, **kwargs) @staticmethod def ShowChannels(patch, *args, **kwargs): _default_visualizer.ShowChannels(ChannelLast(patch), *args, **kwargs)