예제 #1
0
    public static void SVD(float[,] covMat, out float[] s, out float[,] v)
    {
        TFShape shape       = new TFShape(covMat.GetLength(0), covMat.GetLength(1));
        var     reshaped    = covMat.Reshape();
        var     inputTensor = TFTensor.FromBuffer(shape, reshaped, 0, reshaped.Length);

        TFGraph  svdGraph  = new TFGraph();
        TFOutput input     = svdGraph.Placeholder(TFDataType.Float, shape);
        var      svdResult = (ValueTuple <TFOutput, TFOutput, TFOutput>)svdGraph.Svd(input, true);

        var sess   = new TFSession(svdGraph);
        var runner = sess.GetRunner();

        runner.AddInput(input, inputTensor);
        runner.Fetch(svdResult.Item1);
        runner.Fetch(svdResult.Item2);

        TFTensor[] results = runner.Run();
        s = (float[])results[0].GetValue();
        v = (float[, ])results[1].GetValue();
        TFStatus temp = new TFStatus();

        sess.CloseSession(temp);
        sess.DeleteSession(temp);
    }
예제 #2
0
        public void Dispose()
        {
            lock (this)
            {
                if (!IsDisposed)
                {
                    IsDisposed = true;

                    if (TensorSource != null)
                    {
                        foreach (var tensor in TensorSource)
                        {
                            tensor.Dispose();
                        }
                    }
                    if (TensorTarget != null)
                    {
                        foreach (var tensor in TensorTarget)
                        {
                            tensor.Dispose();
                        }
                    }

                    Session?.DeleteSession();
                }
            }
        }
예제 #3
0
        public void Dispose()
        {
            lock (this)
            {
                if (!IsDisposed)
                {
                    IsDisposed = true;

                    if (TensorMicTile != null)
                    {
                        foreach (var tensor in TensorMicTile)
                        {
                            tensor.Dispose();
                        }
                    }
                    if (TensorMicTilePredict != null)
                    {
                        foreach (var tensor in TensorMicTilePredict)
                        {
                            tensor.Dispose();
                        }
                    }
                    if (TensorTrainingLabels != null)
                    {
                        foreach (var tensor in TensorTrainingLabels)
                        {
                            tensor.Dispose();
                        }
                    }
                    if (TensorTrainingWeights != null)
                    {
                        foreach (var tensor in TensorTrainingWeights)
                        {
                            tensor.Dispose();
                        }
                    }

                    Session.DeleteSession();
                }
            }
        }
예제 #4
0
        public void Dispose()
        {
            lock (this)
            {
                if (!IsDisposed)
                {
                    IsDisposed = true;

                    foreach (var tensor in TensorSource)
                    {
                        tensor.Dispose();
                    }
                    foreach (var tensor in TensorWeightSource)
                    {
                        tensor.Dispose();
                    }

                    Session.DeleteSession();
                }
            }
        }
예제 #5
0
파일: BoxNet.cs 프로젝트: smart111/warp
        public void Dispose()
        {
            lock (this)
            {
                if (!IsDisposed)
                {
                    IsDisposed = true;

                    foreach (var tensor in TensorMicTile)
                    {
                        tensor.Dispose();
                    }
                    foreach (var tensor in TensorTrainingLabels)
                    {
                        tensor.Dispose();
                    }

                    Session.DeleteSession();
                }
            }
        }