Coder Social home page Coder Social logo

GenericTensor 2.0 about generictensor HOT 3 OPEN

asc-community avatar asc-community commented on July 18, 2024
GenericTensor 2.0

from generictensor.

Comments (3)

Darelbi avatar Darelbi commented on July 18, 2024 1

It's a pity. I prefer reusing existing libraries, however since this one is no longer maintained I started already doing some small changes. Thank you

https://github.com/Darelbi/NeuraSharp/tree/tensor/NeuraSharp/NeuraSharp.GenericTensor

Here it is. Right now I'm refactoring to use INumer interface, when finished I will try to look at SIMD-izing and use the fast matrix multiplication for the last 2 dimensions. I think the design is already pretty good so no need major changes.

from generictensor.

Darelbi avatar Darelbi commented on July 18, 2024

Hi, I want to add some opinion, I'm writing Machine Learning Stuff, and soon found myself to write stuff that is not available in c#. This library is very close to what I need (and only 1 another library do that). It would save me to write that. (was halfway through)

In machine learning you can have 1D or 2D input, tough sometimes 3D is used for multiple channels of colors in images so is a thin 3D. Sometimes real 3D input is possible. And since it is more convenient to train the neural network in batches of inputs you add 1 extra dimension to all the inputs. (Basicaly pack the inputs togheter, makes the pack one dimension higher than the elements of the pack)

In a neural network there is a operation that is feed forward input which basically is

given a NDimensional series of inputs x1,x2,x3,x4 and a bias b.
and a Weight matrix/tensor (N+1 dimensional) W

the output of the layer of neural network is defined as a(W*(x1|x2|x3|x4) + (b|b|b|b)) = (y1|y2|y3|y4) .. where a is a non-linearity function like sigmoid or tanh applied element-wise to all the results.

basically the Tensor multiplication is the most common used operation and it should be heavily optimized (Parallel.For + SIMD types + dividing the loops in small cache local batches + transpose before multyplying to allow exploit SIMD Vectors better convertin a ROW by COLUMNS product to a COLUMNs by COLUMNS product). If you provide a very good tensor multiplication the library is automatically the best choice for machine learning stuff around there.

Regarding the "Number providers" if you are willing to drop support for old .NET stuff there is already the INumber interface which provides all the stuff the Number providers does in example

public static void MySum<T>(T a, T b) where T:INumber<T>
{
          return a+b+T.One;
 }

Hoping forward to see of the project, if you are willing to implement the Tensor Sum/Multiplication before all other features and release a Prerelease with just that I'll be one of your first users for sure. Also it would be nice the library support extension capability

public interface MyMultiplyBy2Operation<T>  : IUnaryOperation<T> where T:INumber
{
          public T Compute(T Input); // called on residual elements on a SIMD vector
          public Vector<T> Compute(Vector<T> input) // called on core elements to allow SIMD-ization
 }  

that would allow automatically to implement neural networks activation functions.

Regarding the types I would like just a Tensor type with size and dimensional check when you multiply or add 2 toghether.

from generictensor.

WhiteBlackGoose avatar WhiteBlackGoose commented on July 18, 2024

@Darelbi I'm glad you find the idea good. However sadly I don't have time or mood for working on this project anymore. It's an MIT-licensed project, so you're free to continue the work on your own

from generictensor.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.