/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/blob_weighted_sum.py (2219B)
## @package BlobWeightedSum # Module caffe2.python.layers.blob_weighted_sum from caffe2.python import schema from caffe2.python.layers.layers import ModelLayer class BlobWeightedSum(ModelLayer): """ This layer implements the weighted sum: weighted element-wise sum of input blobs. """ def __init__( self, model, input_record, init_weights=None, weight_optim=None, name='blob_weighted_sum', **kwargs ): super(BlobWeightedSum, self).__init__(model, name, input_record, **kwargs) self.blobs = self.input_record.field_blobs() self.num_weights = len(self.blobs) assert self.num_weights > 1, ( "BlobWeightedSum expects more than one input blobs" ) assert len(input_record.field_types()[0].shape) > 0, ( "BlobWeightedSum expects limited dimensions of the input tensor" ) assert all( input_record.field_types()[0].shape == input_record.field_types()[i].shape for i in range(1, self.num_weights) ), "Shape of input blobs should be the same shape {}".format( input_record.field_types()[0].shape ) if init_weights: assert self.num_weights == len(init_weights), ( "the size of init_weights should be the same as input blobs, " "expects {}, got {}".format(self.num_weights, len(init_weights)) ) else: init_weights = [1.0] * self.num_weights self.weights = [ self.create_param( param_name="w_{}".format(idx), shape=[1], initializer=('ConstantFill', {'value': float(init_weights[idx])}), optimizer=weight_optim ) for idx in range(self.num_weights) ] self.output_schema = schema.Scalar( input_record.field_types()[0], self.get_next_blob_reference('blob_weighted_sum_out') ) def add_ops(self, net): net.WeightedSum( [x for pair in zip(self.blobs, self.weights) for x in pair], self.output_schema(), grad_on_w=True, )