Exemplo n.º 1
0
        protected void InitLayerInput(LayerParamaters layerParamaters)
        {
            if (layerParamaters.LayerType != ELayerType.Input)
            {
                throw new InvalidOperationException("This constructor can only be used for input layers");
            }

            Size       = layerParamaters.NeuronCount;
            NeuronType = layerParamaters.NeuronType;
            LayerType  = layerParamaters.LayerType;

            PreviousLayerSize = -1;
        }
Exemplo n.º 2
0
        protected void InitLayer(LayerParamaters layerParamaters, LayerParamaters previousLayer)
        {
            if (layerParamaters.LayerType == ELayerType.Input)
            {
                throw new InvalidOperationException("This constructor cannot be used for input layers");
            }

            Size       = layerParamaters.NeuronCount;
            NeuronType = layerParamaters.NeuronType;
            LayerType  = layerParamaters.LayerType;

            //construct weights array
            PreviousLayerSize = previousLayer.NeuronCount;
            int weightCount = layerParamaters.NeuronCount * previousLayer.NeuronCount;

            Weights = new NativeArray <float>(weightCount, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
            Biases  = new NativeArray <float>(Size, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
        }
Exemplo n.º 3
0
        public static NetworkLayer ConstructLayer(LayerParamaters layerParamaters)
        {
            switch (layerParamaters.NeuronType)
            {
            case ENeruonType.Linear:
                return(new LinearLayer(layerParamaters));

            case ENeruonType.RectifiedLinear:
                return(new RectifiedLinearLayer(layerParamaters));

            case ENeruonType.Sigmoid:
                return(new SigmoidLayer(layerParamaters));

            case ENeruonType.Input:
                return(new InputLayer(layerParamaters));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 4
0
        public static NetworkLayer ConstructLayer(LayerParamaters layerParamaters, LayerParamaters previousLayer)
        {
            switch (layerParamaters.NeuronType)
            {
            case ENeruonType.Linear:
                return(new LinearLayer(layerParamaters, previousLayer));

            case ENeruonType.RectifiedLinear:
                return(new RectifiedLinearLayer(layerParamaters, previousLayer));

            case ENeruonType.Sigmoid:
                return(new SigmoidLayer(layerParamaters, previousLayer));

            case ENeruonType.Input:
                throw new InvalidOperationException("Only the first layer in a network can be a input layer");

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 5
0
 public LinearLayer(LayerParamaters layerParamaters)
 {
     InitLayerInput(layerParamaters);
 }
Exemplo n.º 6
0
 public LinearLayer(LayerParamaters layerParamaters, LayerParamaters previousLayer)
 {
     InitLayer(layerParamaters, previousLayer);
 }
Exemplo n.º 7
0
 public InputLayer(LayerParamaters layerParamaters)
 {
     InitLayerInput(layerParamaters);
 }
Exemplo n.º 8
0
 public SigmoidLayer(LayerParamaters layerParamaters)
 {
     InitLayerInput(layerParamaters);
 }
Exemplo n.º 9
0
 public SigmoidLayer(LayerParamaters layerParamaters, LayerParamaters previousLayer)
 {
     InitLayer(layerParamaters, previousLayer);
 }
Exemplo n.º 10
0
 public RectifiedLinearLayer(LayerParamaters layerParamaters)
 {
     InitLayerInput(layerParamaters);
 }