How I make this function work without Runnable?

30 views Asked by At

I found a basic recurrent neural network in github Here in C#. It is a good example for beginning with recurrent neural network. This is a function in Graph.cs module. My question is, how I make this function work without Runnable?

public Matrix Add(Matrix m1, Matrix m2)
    {
        if (m1.Rows != m2.Rows || m1.Cols != m2.Cols)
        {
            throw new Exception("matrix dimension mismatch");
        }
        Matrix returnObj = new Matrix(m1.Rows, m1.Cols);
        for (int i = 0; i < m1.W.Length; i++)
        {
            returnObj.W[i] = m1.W[i] + m2.W[i];
        }
        if (this.ApplyBackprop)
        {
            Runnable bp = new Runnable();
            bp.Run = delegate()
            {
                for (int i = 0; i < m1.W.Length; i++)
                {
                    m1.Dw[i] += returnObj.Dw[i];
                    m2.Dw[i] += returnObj.Dw[i];
                }
            };
            Backprop.Add(bp);
        }
        return returnObj;
    }
0

There are 0 answers