Ejemplo n.º 1
0
        public Linear(SyftController controller, int input, int output)
        {
            _input  = input;
            _output = output;

            int[] weightShape = { input, output };
            var   weights     = controller.RandomWeights(input * output);

            _weights = new FloatTensor(controller, _shape: weightShape, _data: weights, _autograd: true);

            int[] biasShape = { output };
            _bias = new FloatTensor(controller, biasShape, _autograd: true);
        }
Ejemplo n.º 2
0
        public Embedding(SyftController controller, int numEmbeddings, int embeddingDim)
        {
            init("embedding");

            this.controller = controller;

            _numEmbeddings = numEmbeddings;
            _embeddingDim  = embeddingDim;

            int[] weightShape = { _numEmbeddings, _embeddingDim };
            var   weights     = controller.RandomWeights(_numEmbeddings * _embeddingDim);

            _weights = controller.floatTensorFactory.Create(_shape: weightShape, _data: weights, _autograd: true, _keepgrads: true);

            parameters.Add(_weights.Id);

            #pragma warning disable 420
            id = System.Threading.Interlocked.Increment(ref nCreated);
            controller.addModel(this);
        }