MCPcopy Create free account
hub / github.com/ImprintLab/Medical-SAM2 / forward

Method forward

sam2_train/modeling/sam2_utils.py:95–103  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

93 self.scale_by_keep = scale_by_keep
94
95 def forward(self, x):
96 if self.drop_prob == 0.0 or not self.training:
97 return x
98 keep_prob = 1 - self.drop_prob
99 shape = (x.shape[0],) + (1,) * (x.ndim - 1)
100 random_tensor = x.new_empty(shape).bernoulli_(keep_prob)
101 if keep_prob > 0.0 and self.scale_by_keep:
102 random_tensor.div_(keep_prob)
103 return x * random_tensor
104
105
106# Lightly adapted from

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected