Exemplo n.º 1
0
 public ACTIVATION GetACTIVATIONFromReader(IDataReader reader)
 {
     try
     {
         ACTIVATION aCTIVATION = new ACTIVATION
                                 (
             (int)reader["ACTIVATIONID"],
             (int)reader["CUST_ID"],
             reader["CARRIERTYPE"].ToString(),
             reader["ACTIVATIONTYPE"].ToString(),
             reader["ACCOUNTNO"].ToString(),
             reader["ORDERNO"].ToString(),
             reader["DEALERCODE"].ToString(),
             (DateTime)reader["ACTIVATIONDATE"],
             reader["MOBILENO"].ToString(),
             reader["SIMM"].ToString(),
             reader["IMEI"].ToString(),
             reader["RATEPLAN"].ToString(),
             (int)reader["COMMAMOUNT"],
             (int)reader["SPIFF"],
             (int)reader["REBATE"],
             (char)reader["ISACTIVE"],
             (int)reader["CREATEDBY"],
             (DateTime)reader["CREATEDON"],
             (int)reader["UPDATEDBY"],
             (DateTime)reader["UPDATEDON"]
                                 );
         return(aCTIVATION);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Exemplo n.º 2
0
        public NeuralGroup(string p_id, JSONObject p_data)
        {
            _id  = p_id;
            _dim = int.Parse(p_data["dim"].str);
            _activationFunction = (ACTIVATION)Enum.Parse(typeof(ACTIVATION), p_data["actfn"].str);

            _inConnections = new List <Connection>();
            _outConnection = new List <Connection>();

            _output = Vector.Zero(_dim);
            _ap     = Vector.Zero(_dim);
            _bias   = BasePool.Instance.Get(_dim);

            byte[] buffer = Convert.FromBase64String(p_data["bias"].str);

            MemoryStream stream = new MemoryStream(buffer);
            BinaryReader reader = new BinaryReader(stream);

            for (int i = 0; i < _dim; i++)
            {
                _bias[i] = reader.ReadSingle();
            }

            _derivs = null;
            _valid  = false;
        }
Exemplo n.º 3
0
    public bool UpdateACTIVATION(ACTIVATION aCTIVATION)
    {
        using (SqlConnection connection = new SqlConnection(this.ConnectionString))
        {
            SqlCommand cmd = new SqlCommand("AbiMatuEnterprise_UpdateACTIVATION", connection);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@ACTIVATIONID", SqlDbType.Int).Value        = aCTIVATION.ACTIVATIONID;
            cmd.Parameters.Add("@CUST_ID", SqlDbType.Int).Value             = aCTIVATION.CUST_ID;
            cmd.Parameters.Add("@CARRIERTYPE", SqlDbType.VarChar).Value     = aCTIVATION.CARRIERTYPE;
            cmd.Parameters.Add("@ACTIVATIONTYPE", SqlDbType.VarChar).Value  = aCTIVATION.ACTIVATIONTYPE;
            cmd.Parameters.Add("@ACCOUNTNO", SqlDbType.VarChar).Value       = aCTIVATION.ACCOUNTNO;
            cmd.Parameters.Add("@ORDERNO", SqlDbType.VarChar).Value         = aCTIVATION.ORDERNO;
            cmd.Parameters.Add("@DEALERCODE", SqlDbType.VarChar).Value      = aCTIVATION.DEALERCODE;
            cmd.Parameters.Add("@ACTIVATIONDATE", SqlDbType.DateTime).Value = aCTIVATION.ACTIVATIONDATE;
            cmd.Parameters.Add("@MOBILENO", SqlDbType.VarChar).Value        = aCTIVATION.MOBILENO;
            cmd.Parameters.Add("@SIMM", SqlDbType.VarChar).Value            = aCTIVATION.SIMM;
            cmd.Parameters.Add("@IMEI", SqlDbType.VarChar).Value            = aCTIVATION.IMEI;
            cmd.Parameters.Add("@RATEPLAN", SqlDbType.VarChar).Value        = aCTIVATION.RATEPLAN;
            cmd.Parameters.Add("@COMMAMOUNT", SqlDbType.Int).Value          = aCTIVATION.COMMAMOUNT;
            cmd.Parameters.Add("@SPIFF", SqlDbType.Int).Value          = aCTIVATION.SPIFF;
            cmd.Parameters.Add("@REBATE", SqlDbType.Int).Value         = aCTIVATION.REBATE;
            cmd.Parameters.Add("@ISACTIVE", SqlDbType.Char).Value      = aCTIVATION.ISACTIVE;
            cmd.Parameters.Add("@CREATEDBY", SqlDbType.Int).Value      = aCTIVATION.CREATEDBY;
            cmd.Parameters.Add("@CREATEDON", SqlDbType.DateTime).Value = aCTIVATION.CREATEDON;
            cmd.Parameters.Add("@UPDATEDBY", SqlDbType.Int).Value      = aCTIVATION.UPDATEDBY;
            cmd.Parameters.Add("@UPDATEDON", SqlDbType.DateTime).Value = aCTIVATION.UPDATEDON;
            connection.Open();

            int result = cmd.ExecuteNonQuery();
            return(result == 1);
        }
    }
Exemplo n.º 4
0
    public static ACTIVATION GetACTIVATIONByID(int id)
    {
        ACTIVATION            aCTIVATION            = new ACTIVATION();
        SqlACTIVATIONProvider sqlACTIVATIONProvider = new SqlACTIVATIONProvider();

        aCTIVATION = sqlACTIVATIONProvider.GetACTIVATIONByID(id);
        return(aCTIVATION);
    }
Exemplo n.º 5
0
        public CoreLayer(int p_dim, ACTIVATION p_activationFunction, TYPE p_type) : base(p_type, CORE)
        {
            NeuralGroup core = new NeuralGroup("core", p_dim, p_activationFunction);

            _groups.Add("core", core);

            _inputGroup = _outputGroup = core;
        }
Exemplo n.º 6
0
        public void Add(int size, ACTIVATION a, LOSS l, double bias)
        {
            activation = a;
            loss       = l;

            for (int i = 0; i < size; i++)
            {
                Neuron n = new Neuron(this.Owner);
                n.activation = activation;
                n.loss       = loss;
                n.bias       = bias;
                n.father     = this;

                Neurons.Add(n);
            }
        }
Exemplo n.º 7
0
        public RecurrentLayer(int p_dim, ACTIVATION p_activationFunction, TYPE p_type) : base(p_type, RECURRENT)
        {
            NeuralGroup core    = new NeuralGroup("core", p_dim, p_activationFunction);
            NeuralGroup context = new NeuralGroup("context", p_dim, ACTIVATION.IDENTITY);

            _groups.Add("core", core);
            _groups.Add("context", context);

            Connection c = Connect(context, core, true);

            c.Init(Connection.INIT.LECUN_UNIFORM, 0.05f);

            Connection r = Connect(core, context, false);

            r.Weights = Matrix.Identity(p_dim, p_dim);

            _inputGroup = _outputGroup = core;
        }
Exemplo n.º 8
0
        public NeuralGroup(string p_id, int p_dim, ACTIVATION p_activationFunction)
        {
            _id    = p_id;
            _dim   = p_dim;
            _batch = 0;
            _activationFunction = p_activationFunction;
            _inConnections      = new List <Connection>();
            _outConnection      = new List <Connection>();

            _output   = Vector.Zero(_dim);
            _output_t = null;
            _ap       = Vector.Zero(_dim);
            _ap_t     = null;
            _bias     = Vector.Random(_dim);
            _bias_t   = null;
            //_bias = Vector.Zero(_dim);
            _derivs   = null;
            _derivs_t = null;
            _valid    = false;
        }
Exemplo n.º 9
0
        public void LoadFromCode(List <string> code)
        {
            string s;
            string s2;
            string tag;

            string[] ss;
            string[] ss2;

            Synapse _synapse;
            Neuron  _neuron;
            Layer   _layer;

            Dictionary <int, NeuralObject> mapping = new Dictionary <int, NeuralObject>();

            int        _id          = -1;
            string     _class       = "";
            ACTIVATION _activation  = ACTIVATION.SOFTMAX;
            LOSS       _loss        = LOSS.CROSS_ENTROPY;
            int        _father      = -1;
            double     _bias        = 0.00;
            double     _weight      = 0.00;
            double     _learnfactor = 0.00;
            int        _previous    = -1;
            int        _next        = -1;

            int maxID = -1;

            for (int i = 0; i < code.Count; i++)
            {
                s  = code[i].Trim();
                ss = s.Split('|');

                for (int j = 0; j < ss.Length; j++)
                {
                    s   = ss[j].Trim();
                    ss2 = s.Split(':');
                    s   = ss2[0].Trim();
                    s2  = ss2[1].Trim();

                    switch (s)
                    {
                    default:
                        throw new System.Exception("unknow parameter");

                    case "ID":
                        if (!int.TryParse(s2, out _id))
                        {
                            throw new System.Exception("id not integer");
                        }
                        break;

                    case "Class":
                        _class = s2;
                        break;

                    case "Activation":
                        if (!Enum.TryParse <ACTIVATION>(s2, out _activation))
                        {
                            throw new System.Exception("invalid activation");
                        }
                        break;

                    case "Loss":
                        if (!Enum.TryParse <LOSS>(s2, out _loss))
                        {
                            throw new System.Exception("invalid loss");
                        }
                        break;

                    case "Bias":
                        if (!double.TryParse(s2, out _bias))
                        {
                            throw new System.Exception("bias is not double");
                        }
                        break;

                    case "Father":
                        if (!int.TryParse(s2, out _father))
                        {
                            throw new System.Exception("father not integer");
                        }
                        break;

                    case "Weight":
                        if (!double.TryParse(s2, out _weight))
                        {
                            throw new System.Exception("weight is not double");
                        }
                        break;

                    case "Learn Factor":
                        if (!double.TryParse(s2, out _learnfactor))
                        {
                            throw new System.Exception("learn factor is not double");
                        }
                        break;

                    case "Previous":
                        if (!int.TryParse(s2, out _previous))
                        {
                            throw new System.Exception("previous not integer");
                        }
                        break;

                    case "Next":
                        if (!int.TryParse(s2, out _next))
                        {
                            throw new System.Exception("next not integer");
                        }
                        break;
                    }
                }

                maxID   = maxID < _id ? _id : maxID;
                _lastid = _id;

                switch (_class)
                {
                case "NeuralNetwork":
                    break;

                case "Layer":
                    _layer            = new Layer(this);
                    _layer.activation = _activation;
                    _layer.loss       = _loss;

                    layers.Add(_layer);
                    mapping.Add(_id, _layer);
                    break;

                case "Neuron":
                    _neuron            = new Neuron(this);
                    _neuron.father     = (Layer)mapping[_father];
                    _neuron.bias       = _bias;
                    _neuron.activation = _activation;
                    _neuron.loss       = _loss;

                    layers.Last().Neurons.Add(_neuron);
                    mapping.Add(_id, _neuron);
                    break;

                case "Synapse":
                    _synapse             = new Synapse(this);
                    _synapse.weight      = _weight;
                    _synapse.learnFactor = _learnfactor;
                    _synapse.previous    = (Neuron)mapping[_previous];
                    _synapse.next        = (Neuron)mapping[_next];

                    layers.Last().Synapses.Add(_synapse);
                    mapping.Add(_id, _synapse);
                    break;

                default:
                    break;
                }
            }

            _lastid = maxID + 1;
        }
Exemplo n.º 10
0
    public static bool UpdateACTIVATION(ACTIVATION aCTIVATION)
    {
        SqlACTIVATIONProvider sqlACTIVATIONProvider = new SqlACTIVATIONProvider();

        return(sqlACTIVATIONProvider.UpdateACTIVATION(aCTIVATION));
    }
Exemplo n.º 11
0
    public static int InsertACTIVATION(ACTIVATION aCTIVATION)
    {
        SqlACTIVATIONProvider sqlACTIVATIONProvider = new SqlACTIVATIONProvider();

        return(sqlACTIVATIONProvider.InsertACTIVATION(aCTIVATION));
    }
Exemplo n.º 12
0
 public Nodes(NODE mode, ACTIVATION act, int n)
 {
     init(mode, act, n);
 }
Exemplo n.º 13
0
 public Nodes()
 {
     property   = NODE.IN;
     activation = ACTIVATION.SIN;
     nb         = 0;
 }
Exemplo n.º 14
0
 public void init(NODE mode, ACTIVATION act, int n)
 {
     property   = mode;
     activation = act;
     nb         = n;
 }