Giter VIP home page Giter VIP logo

Comments (10)

kabaka0 avatar kabaka0 commented on May 12, 2024 1

I admit to initially being confused about NewMatrix/Vector - you're right that it does not intuitively suggest node creation. How about having all those routines begin with NewNodeFrom... and NewNodeOf... ?

x:= NewNodeOfVector(g, Float64, 5, WithName("x"))
y:= NewNodeFromVector(g, x, WithName("y"))

It is quite verbose, but given that these are among the first functions any (new) user would have to call, making them easy to understand might be worth it.

from gorgonia.

chewxy avatar chewxy commented on May 12, 2024

Changed

x := IsAVector(g, Float64, 5, WithName("x"))
y := IsAMatrix(g, Flaot32, 2, 3, WithName("y"), WithValue(yT))

to

x := Vector(g, Float64, 5, WithName("x"))
y := Matrix(g, Flaot32, 2, 3, WithName("y"), WithValue(yT))

Reason: IsAVector looks like it should return a bool and is hence confusing.
Cons: now it looks like what I really don't like: Theano's syntax.

from gorgonia.

chewxy avatar chewxy commented on May 12, 2024

I like the idea of NewNodeOf. Clean. Explains itself well. As for the one that has "from"... I think adopting the NodeFromXXX pattern would be cleaner - drop the "the" "new

from gorgonia.

chewxy avatar chewxy commented on May 12, 2024

Changed

x := Vector(g, Float64, 5, WithName("x"))
y := Matrix(g, Flaot32, 2, 3, WithName("y"), WithValue(yT))

to

x := NewNodeOfVector(g, Float64, 5, WithName("x"))
y := NewNodeOfMatrix(g, Float32, 2, 3, WithName("y"), WithValue(yT))

or

x := NodeOfVector(g, Float64, 5, WithName("x"))
y := NodeOfMatrix(g, Float32, 2, 3, WithName("y"), WithValue(yT))

@kabaka0 made some very good points in the comments above.

from gorgonia.

alucantonio avatar alucantonio commented on May 12, 2024

Would it be possible to unify the node creation functions into something like NewNodeFromTensor? Then, for instance, a scalar would just be a 1x1 tensor. Is there any reason why the functions to create a "matrix node" are separate from those that create a "tensor node" or a "scalar node"? Maybe it's a naive question, since I am totally new to the library ;-)

from gorgonia.

chewxy avatar chewxy commented on May 12, 2024

https://godoc.org/gorgonia.org/gorgonia#NodeFromAny

Also the reason for having Scalar value vs Scalar represented as a tensor.Tensor type is that the usual tensor.Tensor is tensor.Dense, which requires A LOT of allocation.

from gorgonia.

alucantonio avatar alucantonio commented on May 12, 2024

Ok, thanks for clarifying this. So, in principle I guess I could always use NodeFromAny to create a scalar-matrix-tensor node, since it takes care of calling the appropriate NewScalar or NewTensor functions. I understand that it's better to have a dedicated function to build scalar nodes (instead of representing them as tensors) for memory allocation, but if I understand correctly, NewMatrix and NewVector are just wrappers for NewTensor, so they are separate functions just for convenience, not to save memory.

from gorgonia.

chewxy avatar chewxy commented on May 12, 2024

NewMatrix and NewVector are just wrappers for NewTensor, so they are separate functions just for convenience, not to save memory.

Specifically the convenience is not having to specify how many dimensions

from gorgonia.

alucantonio avatar alucantonio commented on May 12, 2024

Good. Do you think it would be worth explaining the rationale behind these functions somewhere in the gorgonia.org website?

from gorgonia.

chewxy avatar chewxy commented on May 12, 2024

OH YES!

from gorgonia.

Related Issues (20)

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.