/usr/local/lib64/python3.6/site-packages/caffe2/python/layers
NameSizeModeActions
__pycache__/-0755rm
adaptive_weight.py56870644editdlrm
add_bias.py13960644editdlrm
arc_cosine_feature_map.py73450644editdlrm
batch_huber_loss.py35230644editdlrm
batch_lr_loss.py115770644editdlrm
batch_mse_loss.py23330644editdlrm
batch_normalization.py38230644editdlrm
batch_sigmoid_cross_entropy_loss.py14830644editdlrm
batch_softmax_loss.py45800644editdlrm
blob_weighted_sum.py22190644editdlrm
bpr_loss.py14990644editdlrm
bucket_weighted.py23550644editdlrm
build_index.py19370644editdlrm
concat.py48490644editdlrm
constant_weight.py12080644editdlrm
conv.py50500644editdlrm
dropout.py14100644editdlrm
fc.py92960644editdlrm
fc_without_bias.py19540644editdlrm
fc_with_bootstrap.py127880644editdlrm
feature_sparse_to_dense.py143610644editdlrm
functional.py48750644editdlrm
gather_record.py32600644editdlrm
homotopy_weight.py43060644editdlrm
label_smooth.py35070644editdlrm
last_n_window_collector.py23920644editdlrm
layers.py174120644editdlrm
layer_normalization.py42910644editdlrm
margin_rank_loss.py19510644editdlrm
merge_id_lists.py15000644editdlrm
pairwise_similarity.py35490644editdlrm
position_weighted.py20660644editdlrm
random_fourier_features.py31870644editdlrm
reservoir_sampling.py30130644editdlrm
sampling_train.py22100644editdlrm
sampling_trainable_mixin.py13660644editdlrm
select_record_by_context.py23810644editdlrm
semi_random_features.py58090644editdlrm
sparse_dropout_with_replacement.py39430644editdlrm
sparse_feature_hash.py46180644editdlrm
sparse_itemwise_dropout_with_replacement.py39440644editdlrm
sparse_lookup.py221700644editdlrm
split.py22570644editdlrm
tags.py41140644editdlrm
uniform_sampling.py27790644editdlrm
__init__.py9430644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/caffe2/python/layers/gather_record.py (3260B)
## @package gather_record # Module caffe2.python.layers.gather_record from caffe2.python import core, schema from caffe2.python.layers.layers import ModelLayer class GatherRecord(ModelLayer): """ Given 1-D `indices` tensor, gather elements at `i` in `indices` from all the blobs in `record`. If a blob is a values blob of a list, all the elements included by the list's lengths blob are gathered. For example, Input: indices = [0, 2] record:a = [[0, 1], [2, 3], [4, 5], [6, 7]] record:b:lengths = [0, 1, 2, 3] record:b:items = [0, 1, 2, 3, 4, 5] Output: a = [[0, 1], [4, 5]] b:lengths = [0, 2] b:items = [1, 2] This supports nested list. """ def __init__(self, model, input_record, name='gather_record', **kwargs): super(GatherRecord, self).__init__(model, name, input_record, **kwargs) assert 'indices' in input_record assert 'record' in input_record self.output_schema = schema.NewRecord( model.net, input_record.record.clone_schema()) self._indices = self.input_record.indices() def _gather_scalar(self, net, record, lengths_blob, output_record): if lengths_blob is None: net.Gather([record(), self._indices], output_record()) else: net.LengthsGather([record(), lengths_blob, self._indices], output_record()) def _gather_struct(self, net, record, lengths_blob, output_record): for name, field in record.get_children(): self._dispatch(net, field, lengths_blob, output_record[name]) def _gather_list(self, net, record, lengths_blob, output_record): self._gather_scalar( net, record.lengths, lengths_blob, output_record.lengths) if lengths_blob is None: lengths_blob = record.lengths() else: # TODO(kittipat): This is a hacky solution until LengthsSum for int # is implemented lengths_float = net.Cast( record.lengths(), net.NextScopedBlob(str(record.lengths()) + '_float'), to=core.DataType.FLOAT, ) lengths_blob_float = net.LengthsSum( [lengths_float, lengths_blob], net.NextScopedBlob(str(record.lengths()) + "_nested_float") ) lengths_blob = net.Cast( lengths_blob_float, net.NextScopedBlob(str(record.lengths()) + "_nested"), to=core.DataType.INT32, ) self._dispatch(net, record._items, lengths_blob, output_record._items) def _dispatch(self, net, record, lengths_blob, output_record): if isinstance(record, schema.Scalar): self._gather_scalar(net, record, lengths_blob, output_record) elif isinstance(record, schema.Struct): self._gather_struct(net, record, lengths_blob, output_record) elif isinstance(record, schema.List): self._gather_list(net, record, lengths_blob, output_record) else: raise NotImplementedError def add_ops(self, net): self._dispatch(net, self.input_record.record, None, self.output_schema)