/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/position_weighted.py (2066B)
## @package position_weighted # Module caffe2.python.layers.position_weighted import logging import numpy as np from caffe2.python import schema from caffe2.python.layers.layers import ( get_categorical_limit, ModelLayer, ) from caffe2.python.layers.tags import Tags logger = logging.getLogger(__name__) class PositionWeighted(ModelLayer): def __init__(self, model, input_record, weight_optim=None, name="position_weights"): super(PositionWeighted, self).__init__(model, name, input_record) assert isinstance(input_record, schema.List), "Incorrect input type" length_metadata = input_record.lengths.metadata max_length = (length_metadata.categorical_limit if length_metadata is not None else None) if max_length is not None: self.shape = max_length else: self.shape = get_categorical_limit(input_record) logger.warning( '{}: categorical_limit of lengths is not available, using ' 'categorical_limit of the keys: {}'.format( str(input_record.lengths()), self.shape)) self.pos_w = self.create_param(param_name='pos_w', shape=[self.shape, ], initializer=('ConstantFill', {'value': 1.0}), optimizer=weight_optim) self.output_schema = schema.Struct( ('position_weights', schema.Scalar((np.float32, self.shape), self.get_next_blob_reference("pos_w_gather"))) ) self.tags.update({Tags.HANDLE_AS_SPARSE_LAYER}) def get_memory_usage(self): return self.shape def add_ops(self, net): inc_seq = net.LengthsRangeFill( [self.input_record.lengths()], self.input_record.lengths() + '_pos_w_seq' ) net.Gather( [self.pos_w, inc_seq], self.output_schema.position_weights.field_blobs())