Giter Site home page Giter Site logo

Comments (9)

sbadredd avatar sbadredd commented on May 27, 2024

Hi Milena,

Can you send me the rest of your code so I can have a look?

At first glance, this seems to be a TensorFlow error, not related to ltn. If you write:

mask = (labels_position=="P")
tensor_P = features[mask]
x_P = ltn.variable("P", tensor_P)
  • Does the error occur on the second line?
  • If yes, can you check the value and type of mask, is it a tf.Tensor/np.ndarray, or a scalar value? It seems that in your case, mask could be just a boolean, which would cause the Tensorflow error mask cannot be scalar
  • If mask is not a tf.Tensor, you need to convert labels_position to a tensor beforehand. Also, try writing mask = tf.equal(labels_position,"P") to be more explicit

Hope it helps!

from logictensornetworks.

MilenaTenorio avatar MilenaTenorio commented on May 27, 2024

Hi!

Thank you very much for the feedback, I will carry out the suggestions sent.
I can tell you what worked correctly in my code and share the link to access it

It will certainly help me

from logictensornetworks.

MilenaTenorio avatar MilenaTenorio commented on May 27, 2024

Dear,

I add the code suggested:

    mask = (labels_position=="P")
    tensor_P = features[mask]

here:
mask = (labels_position=="P")-> return: FALSE
and
tensor_P = features[mask] -> return:


ValueError: in converted code:

    <ipython-input-13-f5edfa7f8178>:8 axioms *
        tensor_P = features[mask]
    C:\Users\Milena\Anaconda3\lib\site-packages\tensorflow\python\ops\array_ops.py:600 _slice_helper
        return boolean_mask(tensor=tensor, mask=slice_spec)
    C:\Users\Milena\Anaconda3\lib\site-packages\tensorflow\python\ops\array_ops.py:1365 boolean_mask
        raise ValueError("mask cannot be scalar.")

    ValueError: mask cannot be scalar.

from logictensornetworks.

MilenaTenorio avatar MilenaTenorio commented on May 27, 2024

I have made a summary of the code with information that I believe is relevant to the problem I am currently trying to solve.
It's shared: spatialrelation-resume.git

from logictensornetworks.

MilenaTenorio avatar MilenaTenorio commented on May 27, 2024

Now I'll try to convert labels_position to a tensor beforehand!

Thanks for your support!

from logictensornetworks.

sbadredd avatar sbadredd commented on May 27, 2024

With pleasure!

Writing something like:

mask_P = tf.equal(tf.constant(labels_position),"P")
tensor_P = features[mask_P]

should help.

from logictensornetworks.

sbadredd avatar sbadredd commented on May 27, 2024

By the way, if the variable is empty (there are no values of label "P"), the code will return an error when you write your formula.
So maybe add something like:

axioms = []
if tf.reduce_sum(tf.cast(mask_P,tf.int32)) != 0:                     # Only if x_P is not empty...
    axioms.append(Forall(x_P,p([x_P,class_P],training=training)))    # ... add the axiom

In the future, I might add some verifications for cases where the variables are empty

from logictensornetworks.

MilenaTenorio avatar MilenaTenorio commented on May 27, 2024

Thank you very much for the support

from logictensornetworks.

gaokun12 avatar gaokun12 commented on May 27, 2024

from logictensornetworks.

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.