Giter Club home page Giter Club logo

Comments (4)

mschmidt87 avatar mschmidt87 commented on June 16, 2024

I think that the constant float / torch.nn.Parameter needs to be unsqueezed and then the 0-th dimension needs to be blown up to the batch dimension. Something like this:
self._output_str = 'torch.cat(x.shape[0] * [self._p{}.unsqueeze(0)])'.format(self._idx)

from hal-cgp.

jakobj avatar jakobj commented on June 16, 2024

i'm not even sure what the CGPConstantFloat.format_output_str_torch method does, is it even used? it does not make use of the actual value of the node (self._output) but only of the node index to define a new member variable. maybe that function should never be called in the first place (add raise ...?), but only the function format_parameter_str that should actually be called format_parameter_str_torch? in this function, one could just resize the tensor to include a batch dimension, correct?

from hal-cgp.

mschmidt87 avatar mschmidt87 commented on June 16, 2024

As far as I understand, the CGPConstantFloat.format_output_str_torch is called in CGPGraph.compile_torch_class() when the forward method of the torch class is written:
https://github.com/jakobj/python-gp/blob/3bdff24be10ef503652b44b0be1606a639555627/gp/cgp_graph.py#L218

This function calls format_output_str_torch is called on the output nodes here which call this method on their input nodes leading to a recursive call.

On the other hand, the format_parameter_str method is used to construct the __init__() method of the torch class:
https://github.com/jakobj/python-gp/blob/3bdff24be10ef503652b44b0be1606a639555627/gp/cgp_graph.py#L200

This makes sense because in the __init__() method, the constant float has to be defined (for example set to 1.0) and then in the forward method it is used.

from hal-cgp.

jakobj avatar jakobj commented on June 16, 2024

ah i see, thanks for explaining! who the hell wrote that code? ;)

from hal-cgp.

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.