MCPcopy Create free account
hub / github.com/breeze-sys/Label-Only-MIA-Go / VectorScale

Function VectorScale

pkg/mathutils/basic.go:60–66  ·  view source on GitHub ↗

VectorScale 向量与标量相乘 对应 Python: v * scalar (梯度缩放、步长控制)

(v []float32, s float32)

Source from the content-addressed store, hash-verified

58// VectorScale 向量与标量相乘
59// 对应 Python: v * scalar (梯度缩放、步长控制)
60func VectorScale(v []float32, s float32) []float32 {
61 result := make([]float32, len(v))
62 for i := 0; i < len(v); i++ {
63 result[i] = v[i] * s
64 }
65 return result
66}
67
68// Clip 将向量中的每个元素限制在 [min, max] 范围内
69// 对应 Python: np.clip (ART 中的 clip_image 核心)

Callers 3

TestFullBenchmarkFunction · 0.92
AttackMethod · 0.92
approximateGradientMethod · 0.92

Calls

no outgoing calls

Tested by 1

TestFullBenchmarkFunction · 0.74