Beispiel #1
0
        public static KerasSymbol Selu(KerasSymbol x)
        {
            var alpha = 1.6732632423543772f;
            var scale = 1.0507009873554805f;

            return(scale * K.Elu(x, alpha));
        }
Beispiel #2
0
        public static KerasSymbol Logcosh(KerasSymbol y_true, KerasSymbol y_pred)
        {
            var x        = y_pred - y_true;
            var _logcosh = x + K.Softplus(-2 * x) - (float)Math.Log(2);

            return(K.Mean(_logcosh, axis: -1));
        }
Beispiel #3
0
        public static KerasSymbol CategorialHinge(KerasSymbol y_true, KerasSymbol y_pred)
        {
            var pos = K.Sum(y_true * y_pred, axis: -1);
            var neg = K.Max((1 - y_true) * y_pred, axis: -1);

            return(K.Maximum(0, neg - pos + 1));
        }
Beispiel #4
0
        public static KerasSymbol MeanSquaredLogrithmicError(KerasSymbol y_true, KerasSymbol y_pred)
        {
            var first_log  = K.Log(K.Clip(y_pred, K.Epsilon(), null) + 1);
            var second_log = K.Log(K.Clip(y_true, K.Epsilon(), null) + 1);

            return(K.Mean(K.Square(first_log - second_log), axis: -1));
        }
        public static KerasSymbol operator %(KerasSymbol lhs, KerasSymbol rhs)
        {
            KerasSymbol ret = null;

            using (var op = new Operator("_mod"))
            {
                ret = op.Set(lhs, rhs).CreateSymbol("mod");
            }

            return(ret);
        }
        public static KerasSymbol operator %(KerasSymbol lhs, float scalar)
        {
            KerasSymbol ret = null;

            using (var op = new Operator("_mod_scalar"))
            {
                ret = op.Set(lhs, scalar).CreateSymbol("mod");
            }

            return(ret);
        }
Beispiel #7
0
        public static KerasSymbol Softmax(KerasSymbol x, int axis = -1)
        {
            var ndim = K.NDim(x);

            if (ndim == 2)
            {
                return(K.Softmax(x));
            }
            else if (ndim > 2)
            {
                var e = K.Exp(x - K.Max(x, axis: axis, keepdims: true));
                var s = K.Sum(e, axis: axis, keepdims: true);
                return(e / s);
            }
            else if (ndim == 0)
            {
                // x dim is not inferred yet
                return(K.Softmax(x));
            }
            else
            {
                throw new Exception($"Cannot apply softmax to a tensor that is 1D. Received input: {x}");
            }
        }
Beispiel #8
0
 public static KerasSymbol OnesLike(KerasSymbol x, DType dtype = null, string name = "")
 {
     throw new NotImplementedException();
 }
Beispiel #9
0
 public static KerasSymbol Softplus(KerasSymbol x)
 {
     return(K.Softplus(x));
 }
Beispiel #10
0
 public static KerasSymbol Cast(KerasSymbol x, DType dtype)
 {
     throw new NotImplementedException();
 }
Beispiel #11
0
 public static KerasSymbol Elu(KerasSymbol x, float alpha = 1)
 {
     return(K.Elu(x, alpha));
 }
Beispiel #12
0
 public static KerasSymbol HardSigmoid(KerasSymbol x)
 {
     return(K.HardSigmoid(x));
 }
Beispiel #13
0
 public static KerasSymbol Linear(KerasSymbol x)
 {
     return(x);
 }
Beispiel #14
0
 public static KerasSymbol Gather(KerasSymbol reference, KerasSymbol indices)
 {
     throw new NotImplementedException();
 }
Beispiel #15
0
 public static KerasSymbol Tanh(KerasSymbol x)
 {
     return(K.Tanh(x));
 }
Beispiel #16
0
 public static KerasSymbol BatchDot(KerasSymbol x, KerasSymbol y, Shape axes = null)
 {
     throw new NotImplementedException();
 }
Beispiel #17
0
 public static KerasSymbol Transpose(KerasSymbol x)
 {
     throw new NotImplementedException();
 }
Beispiel #18
0
 public static KerasSymbol Dot(KerasSymbol x, KerasSymbol y)
 {
     throw new NotImplementedException();
 }
Beispiel #19
0
 public static KerasSymbol MovingAverageUpdate(KerasSymbol x, NDArray value, float momentum)
 {
     throw new NotImplementedException();
 }
Beispiel #20
0
 public static KerasSymbol UpdateSub(KerasSymbol x, NDArray new_x)
 {
     throw new NotSupportedException("MXNet Backend: Update operations are not supported yet.");
 }
Beispiel #21
0
 public static KerasSymbol Softsign(KerasSymbol x)
 {
     return(K.Softsign(x));
 }
Beispiel #22
0
 public static KerasSymbol Identity(KerasSymbol x)
 {
     throw new NotImplementedException();
 }
Beispiel #23
0
 public static KerasSymbol Relu(KerasSymbol x, float alpha = 0, float?max_value = null, float threshold = 0)
 {
     return(K.Relu(x, alpha: alpha, max_value: max_value, threshold: threshold));
 }
Beispiel #24
0
 public static KerasSymbol Prod(KerasSymbol x, int axis, bool keepdims = false)
 {
     throw new NotImplementedException();
 }
Beispiel #25
0
 public static KerasSymbol Sigmoid(KerasSymbol x)
 {
     return(K.Sigmoid(x));
 }
Beispiel #26
0
 public static KerasSymbol CumProd(KerasSymbol x, int axis = 0)
 {
     throw new NotSupportedException("MXNet Backend: CumProd operations are not supported yet.");
 }
Beispiel #27
0
 public static KerasSymbol Exponential(KerasSymbol x)
 {
     return(K.Exp(x));
 }
Beispiel #28
0
 public static KerasSymbol ToDense(KerasSymbol tensor)
 {
     throw new NotImplementedException();
 }
Beispiel #29
0
 public static KerasSymbol Embedding(KerasSymbol data, KerasSymbol weight, int input_dim, int output_dim, bool sparse_grad = false)
 {
     throw new NotImplementedException();
 }
Beispiel #30
0
 public static int CountParams(KerasSymbol x)
 {
     throw new NotImplementedException();
 }