Esempio n. 1
0
        protected Connection Connect(NeuralGroup p_g1, NeuralGroup p_g2, bool p_trainable = true)
        {
            Connection c = new Connection(p_g1, p_g2, p_trainable);

            p_g1.AddOutConnection(c);
            p_g2.AddInConnection(c);
            _connections.Add(c.Id, c);

            return(c);
        }
Esempio n. 2
0
        public BaseLayer(JSONObject p_data)
        {
            _gradients = new Dictionary <string, Matrix>();

            JSONObject groups = p_data["groups"];

            _id   = p_data["id"].str;
            _type = (TYPE)Enum.Parse(typeof(TYPE), p_data["layer_type"].str);

            _groups = new Dictionary <string, NeuralGroup>();

            foreach (string key in groups.keys)
            {
                JSONObject layer = groups[key];

                NeuralGroup g = new NeuralGroup(key, layer);

                _groups.Add(key, g);

                if (key.Equals(p_data["ingroup"].str))
                {
                    _inputGroup = g;
                }
                if (key.Equals(p_data["outgroup"].str))
                {
                    _outputGroup = g;
                }
            }

            _connections = new Dictionary <string, Connection>();

            if (p_data.HasField("connections"))
            {
                JSONObject connections = p_data["connections"];

                foreach (string key in connections.keys)
                {
                    JSONObject connection = connections[key];

                    NeuralGroup inGroup  = connection.HasField("ingroup") ? _groups[connection["ingroup"].str] : null;
                    NeuralGroup outGroup = _groups[connection["outgroup"].str];

                    Connection c = new Connection(key, inGroup, outGroup, connection);

                    _connections.Add(key, c);

                    if (inGroup != null)
                    {
                        inGroup.AddOutConnection(c);
                    }
                    outGroup.AddInConnection(c);
                }
            }
        }