Comments (9)
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 atf.Tensor
/np.ndarray
, or a scalar value? It seems that in your case,mask
could be just a boolean, which would cause the Tensorflow errormask cannot be scalar
- If
mask
is not atf.Tensor
, you need to convertlabels_position
to a tensor beforehand. Also, try writingmask = tf.equal(labels_position,"P")
to be more explicit
Hope it helps!
from logictensornetworks.
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.
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.
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.
Now I'll try to convert labels_position to a tensor beforehand!
Thanks for your support!
from logictensornetworks.
With pleasure!
Writing something like:
mask_P = tf.equal(tf.constant(labels_position),"P")
tensor_P = features[mask_P]
should help.
from logictensornetworks.
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.
Thank you very much for the support
from logictensornetworks.
from logictensornetworks.
Related Issues (20)
- Lambda for functions need to be implemented using Functional API of TF HOT 2
- Add PEP 484 Type Annotations
- Add tests
- Create classes for Variable, Constant and Proposition
- Support masks using LTN syntax instead of TensorFlow operations
- Add a constructor for variables made from trainable constants
- Parent classes for Terms and Formulas
- Adapt examples to API changes
- Adapt tutorials to API changes
- Add runtime Type Checking when constructing expressions
- Error in the axioms of the clustering example HOT 1
- Using wrapper with new version HOT 1
- automated translation of tptp problems to ltn axioms HOT 1
- Allow to permanently `diag` variables
- Imbalanced classification HOT 3
- Saving LTN model HOT 3
- Weighted connective operators HOT 1
- Add a ltn.Predicate constructor that takes in a logits model HOT 1
- Update tensorflow dependency for apple silicon machines
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from logictensornetworks.