public override Symbol Build(Symbol data) { var weightName = UUID.GetID(ID + "_w"); var biasName = UUID.GetID(ID + "_b"); var bias = UseBias ? Symbol.Variable(biasName) : null; InitParams.Add(weightName, KernalInitializer); if (UseBias) { InitParams.Add(biasName, BiasInitializer); } ConstraintParams.Add(weightName, KernalConstraint); if (UseBias) { ConstraintParams.Add(biasName, BiasConstraint); } RegularizerParams.Add(weightName, KernalRegularizer); if (UseBias) { RegularizerParams.Add(biasName, BiasRegularizer); } var l = sym.FullyConnected(data, Symbol.Variable(weightName), Dim, bias, !UseBias, true, ID); if (Activation != ActivationType.Linear) { var act = ActivationRegistry.Get(Activation); l = act.Build(l); } return(l); }
public override Symbol Build(Symbol x) { var weightName = UUID.GetID(ID + "_w"); InitParams.Add(weightName, EmbeddingsInitializer); ConstraintParams.Add(weightName, EmbeddingsConstraint); RegularizerParams.Add(weightName, EmbeddingsRegularizer); return(sym.Embedding(x, Symbol.Variable(weightName), InputDim, OutputDim, symbol_name: ID)); }
public override Symbol Build(Symbol x) { var biasName = UUID.GetID(ID + "_b"); var weightName = UUID.GetID(ID + "_w"); var bias = UseBias ? Symbol.Variable(biasName) : null; Shape pad = null; if (Padding.HasValue) { pad = new Shape(Padding.Value, Padding.Value, Padding.Value); } else { pad = new Shape(); } if (UseBias) { InitParams.Add(biasName, BiasInitializer); } InitParams.Add(weightName, KernalInitializer); ConstraintParams.Add(weightName, KernalConstraint); if (UseBias) { ConstraintParams.Add(biasName, BiasConstraint); } RegularizerParams.Add(weightName, KernalRegularizer); if (UseBias) { RegularizerParams.Add(biasName, BiasRegularizer); } var conv = sym.Deconvolution(x, Symbol.Variable(weightName), new Shape(KernalSize.Item1, KernalSize.Item2, KernalSize.Item3), Filters, new Shape(Strides.Item1, Strides.Item2, Strides.Item3), new Shape(DialationRate.Item1, DialationRate.Item2, DialationRate.Item3), pad, new Shape(), new Shape(), bias, !UseBias, 1, 512, null, false, null, ID); if (Activation != ActivationType.Linear) { var act = ActivationRegistry.Get(Activation); conv = act.Build(conv); } return(conv); }
public override Symbol Build(Symbol x) { var beta = UUID.GetID(ID + "_beta"); var gamma = UUID.GetID(ID + "_beta"); var movingMean = UUID.GetID(ID + "_mean"); var movingVar = UUID.GetID(ID + "_var"); InitParams.Add(beta, BetaInitializer); InitParams.Add(gamma, GammaInitializer); InitParams.Add(movingMean, MovingMeanInitializer); InitParams.Add(movingVar, MovingVarianceInitializer); ConstraintParams.Add(beta, BetaConstraint); ConstraintParams.Add(gamma, GammaConstraint); RegularizerParams.Add(beta, BetaRegularizer); RegularizerParams.Add(gamma, GammaRegularizer); return(sym.BatchNorm(x, Symbol.Variable(gamma), Symbol.Variable(beta), Symbol.Variable(movingMean), Symbol.Variable(movingVar), Epsilon, Momentum, Center, Scale, false, Axis, false, ID)); }
public abstract bool SetConstraintParam(BulletConstraint constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis);
public abstract bool SetConstraintParam(BulletConstraint constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis);
//m_constraint.ptr, ConstraintParams.BT_CONSTRAINT_STOP_CFM, cfm, ConstraintParamAxis.AXIS_ALL public override bool SetConstraintParam(BulletConstraint pConstraint, ConstraintParams paramIndex, float paramvalue, ConstraintParamAxis axis) { Generic6DofConstraint constrain = (pConstraint as BulletConstraintXNA).constrain as Generic6DofConstraint; if (axis == ConstraintParamAxis.AXIS_LINEAR_ALL || axis == ConstraintParamAxis.AXIS_ALL) { constrain.SetParam((BulletXNA.BulletDynamics.ConstraintParams) (int) paramIndex, paramvalue, 0); constrain.SetParam((BulletXNA.BulletDynamics.ConstraintParams) (int) paramIndex, paramvalue, 1); constrain.SetParam((BulletXNA.BulletDynamics.ConstraintParams) (int) paramIndex, paramvalue, 2); } if (axis == ConstraintParamAxis.AXIS_ANGULAR_ALL || axis == ConstraintParamAxis.AXIS_ALL) { constrain.SetParam((BulletXNA.BulletDynamics.ConstraintParams)(int)paramIndex, paramvalue, 3); constrain.SetParam((BulletXNA.BulletDynamics.ConstraintParams)(int)paramIndex, paramvalue, 4); constrain.SetParam((BulletXNA.BulletDynamics.ConstraintParams)(int)paramIndex, paramvalue, 5); } if (axis == ConstraintParamAxis.AXIS_LINEAR_ALL) { constrain.SetParam((BulletXNA.BulletDynamics.ConstraintParams)(int)paramIndex, paramvalue, (int)axis); } return true; }
public override bool SetConstraintParam(BulletConstraint constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis) { BulletConstraintUnman constrainu = constrain as BulletConstraintUnman; return BSAPICPP.SetConstraintParam2(constrainu.ptr, paramIndex, value, axis); }
public static extern bool SetConstraintParam2(IntPtr constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis);
//m_constraint.ptr, ConstraintParams.BT_CONSTRAINT_STOP_CFM, cfm, ConstraintParamAxis.AXIS_ALL internal static bool SetConstraintParam2(object pConstraint, ConstraintParams paramIndex, float paramvalue, ConstraintParamAxis axis) { Generic6DofConstraint constrain = pConstraint as Generic6DofConstraint; if (axis == ConstraintParamAxis.AXIS_LINEAR_ALL || axis == ConstraintParamAxis.AXIS_ALL) { constrain.SetParam((BulletXNA.BulletDynamics.ConstraintParams) (int) paramIndex, paramvalue, 0); constrain.SetParam((BulletXNA.BulletDynamics.ConstraintParams) (int) paramIndex, paramvalue, 1); constrain.SetParam((BulletXNA.BulletDynamics.ConstraintParams) (int) paramIndex, paramvalue, 2); } if (axis == ConstraintParamAxis.AXIS_ANGULAR_ALL || axis == ConstraintParamAxis.AXIS_ALL) { constrain.SetParam((BulletXNA.BulletDynamics.ConstraintParams)(int)paramIndex, paramvalue, 3); constrain.SetParam((BulletXNA.BulletDynamics.ConstraintParams)(int)paramIndex, paramvalue, 4); constrain.SetParam((BulletXNA.BulletDynamics.ConstraintParams)(int)paramIndex, paramvalue, 5); } if (axis == ConstraintParamAxis.AXIS_LINEAR_ALL) { constrain.SetParam((BulletXNA.BulletDynamics.ConstraintParams)(int)paramIndex, paramvalue, (int)axis); } return true; }
public void SetParam(ConstraintParams num, float value, int axis) { if ((axis >= 0) && (axis < 3)) { switch (num) { case ConstraintParams.BT_CONSTRAINT_STOP_ERP: m_linearLimits.m_stopERP[axis] = value; m_flags |= (int)SixDofFlags.BT_6DOF_FLAGS_ERP_STOP << (axis * BT_6DOF_FLAGS_AXIS_SHIFT); break; case ConstraintParams.BT_CONSTRAINT_STOP_CFM: m_linearLimits.m_stopCFM[axis] = value; m_flags |= (int)SixDofFlags.BT_6DOF_FLAGS_CFM_STOP << (axis * BT_6DOF_FLAGS_AXIS_SHIFT); break; case ConstraintParams.BT_CONSTRAINT_CFM: m_linearLimits.m_normalCFM[axis] = value; m_flags |= (int)SixDofFlags.BT_6DOF_FLAGS_CFM_NORM << (axis * BT_6DOF_FLAGS_AXIS_SHIFT); break; default: Debug.Assert(false); break; } } else if ((axis >= 3) && (axis < 6)) { switch (num) { case ConstraintParams.BT_CONSTRAINT_STOP_ERP: m_angularLimits[axis - 3].m_stopERP = value; m_flags |= (int)SixDofFlags.BT_6DOF_FLAGS_ERP_STOP << (axis * BT_6DOF_FLAGS_AXIS_SHIFT); break; case ConstraintParams.BT_CONSTRAINT_STOP_CFM: m_angularLimits[axis - 3].m_stopCFM = value; m_flags |= (int)SixDofFlags.BT_6DOF_FLAGS_CFM_STOP << (axis * BT_6DOF_FLAGS_AXIS_SHIFT); break; case ConstraintParams.BT_CONSTRAINT_CFM: m_angularLimits[axis - 3].m_normalCFM = value; m_flags |= (int)SixDofFlags.BT_6DOF_FLAGS_CFM_NORM << (axis * BT_6DOF_FLAGS_AXIS_SHIFT); break; default: Debug.Assert(false); break; } } else { Debug.Assert(false); } }