public static void SingleOutputBackward(NdArray <Real> y, NdArray <Real> x, NdArray <Real> mask, NdArray <Real> weight, NdArray <Real> bias, ComputeKernel backwardgWKernel, ComputeKernel backwardgXKernel, ICompressibleActivation <Real> activation) { NdArray <Real> maskedWeight = weight * mask; maskedWeight.InitGrad();//MaskedWeightはOptimizerの対象にならない非パラメータの為初期化が必要 SingleOutputBackward(y, x, maskedWeight, bias, backwardgWKernel, backwardgXKernel, activation); for (int i = 0; i < weight.Data.Length; i++) { mask.Grad[i] = maskedWeight.Grad[i]; //マスク前の重みの傾きをマスクの傾きへ退避 weight.Grad[i] += mask.Data[i] * maskedWeight.Grad[i]; //マスクした傾きを適用 } }