-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: TFValueOf #2004
Comments
Off-topic, but there's another bonus side-effect: If we have a
and then the python function could save local state into the pyDict, instead of storing it in ValuePtr. Basically, it would store whatever you wanted to stick into ValuePtr. And also store any other python stuff you might ever want to store. You'd use it like so:
In particular, large parts, or most of, or even all of today's So, then to make it easy for
so that |
So if I understand this one point correctly: if we have a GPN that is
naturally thought of as returning some sort of complex TruthValue
object, this TruthValue would be attached to the EvaluationLink?
…On Tue, Jan 22, 2019 at 3:39 AM Linas Vepštas ***@***.***> wrote:
Off-topic, but there's another bonus side-effect: If we have a NewGroundedPredicateNode that takes the EvaluationLink as the first argument, then would could introduce a PythonEvaluationLink, as a kind-of EvaluationLink, but it would have a C++ class behind it, that looks like this:
class PythonEvaluationLink : EvaluationLink {
private:
PyObject* pyDict;
PyObject* pyUserFunc;
public:
PythonEvaluationLink() {
pyDict = PyModule_GetDict(pyModule);
pyUserFunc = PyDict_GetItem(pyDict, "whatever");
}
and then the python function could save local state into the pyDict, instead of storing it in ValuePtr. Basically, it would store whatever you wanted to stick into ValuePtr. And also store any other python stuff you might ever want to store.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
--
Ben Goertzel, PhD
http://goertzel.org
"The dewdrop world / Is the dewdrop world / And yet, and yet …" --
Kobayashi Issa
|
I suppose you mean, change |
So, if understand correctly you want to use a bit of |
Do you mean that (TimesLink (TruthValueOf A) (TruthValueOf B)) Yeah, that + short-hands like
When confidence isn't taken into account, yes there are simple arithmetic. When confidence is taken into account, it's another story, it ideally requires a form of numerical integration, but sure, with adequate operators, we could (and ultimately should) do that. |
Also, as much as I like the idea of using boolean value for pattern matcher, we already have But I would also be perfectly happy to have a I'm not against storing some TFValue in |
Currently (cog-evaluate! (Inheritance (stv 0.5 0.5) (Concept "A") (Concept "B"))) returns (stv 0.5 0.5) It also looks like For instance (cog-tv (cog-execute! (Inheritance (stv 0.5 0.5) (Concept "A") (Concept "B")))) is equivalent to (cog-evaluate! (Inheritance (stv 0.5 0.5) (Concept "A") (Concept "B"))) However (cog-tv (cog-execute! (Evaluation (GroundedPredicate "my-gpn") (Concept "my-arg")))) is not equivalent to (cog-evaluate! (Evaluation (GroundedPredicate "my-gpn") (Concept "my-arg"))) as it returns Maybe that is why you, @linas , suggest to store the resulting |
It seems that there two separate usecases for logical operators in Atomese:
It makes sense to separate this usecases by using different names e.g. PMOrLink which would expect boolean values and OrLink AndLink, IfThenElse etc. links which would be interpreted by URE or other interpreter. |
For me main question of the issue is: PatternMatcher uses boolean logic, but @linas, as I see you have suggested adding boolean values into atomspace but why not introduce If PatternMatcher query includes calculation of some atom which returns |
I think instead of (Get
(And
(Inheritance (Variable "$X") (Variable "$Y"))
(Inheritance (Variable "$Y") (Variable "$Z"))
(Equal (Variable "$X") (Variable "$Z")))) one should write (Get
(And
(Present
(Inheritance (Variable "$X") (Variable "$Y"))
(Inheritance (Variable "$Y") (Variable "$Z")))
(Equal (Variable "$X") (Variable "$Z"))))
I know that it adds an extra
but you can also write
The beauty is that |
@ngeiswei, it is an excellent idea, we have discussed same thing with @noskill yesterday, but I didn't remember about I would add that in case if you need to calculate some predicate on grounded variable during pattern matching then you need some way to convert |
Responding in chronological order. @bgoertzel asks:
Yes. If two different EvalLinks call the same GPN, then the return value is kept with the EvalLink that called it. And more: the EvalLink can keep track of all of the hidden state needed to make that GPN work efficiently. |
@ngeiswei asks
No, I mean get rid of TV entirely. It is useless and completely unused; when you red through the code, all of it does some version of this:
which is dorky and pointless and a waste of CPU cycles. Instead, I propose this:
No waste, no fuss, no memory-reference counting, no pointless creation of TV values which are then immediately discarded. |
I do not recall saying "virtual link" anywhere. I meant ordinary Atom. Perhaps this can be done without storing, but this is not obvious. Having a cached value you can always get, instead of always being force to recompute it is convenient. But perhaps it does not need to be stored. I'd have to think about that more. |
Remaining questions later; not ignoring you just busy. |
Well, as long as one can create grounded function to return TruthValue (or any Value type) I'm OK with that. It's just that in OpenCog/PLN literature a predicate node outputs TV. That isn't to say we can't change it. Or maybe we'd want to create a subtype |
@ngeiswei asks:
You asked three questions, the answers are: No, yes, and yes. First question: "Do you mean that PlusLink, TimesLink, etc, could accept Value," No. Links are still links, same as they ever were, and can only have atoms in their outgoing set; never values. However, many atoms are evaluatable. Such as EvaluationLink and ValueOfLink. If evaluatable atoms return values that can be interpreted as numbers, then PlusLink, TimesLink, etc, can add and multiply those numbers. '''This already works today''', it was implemented last summer, so that the neural net guys (@Necr0x0Der and crew) could use it for their neural nets. The working demo is here: https://github.com/opencog/atomspace/blob/master/examples/atomspace/stream.scm Third question/remark: " By the way, why does approximately half the code call it "mean", and the other half call it "strength"? Maybe we can pick one, or the other? Finally, you made a comment:
I mean "normal arithmetic" and not a simplified version of it. (there is a thing called "simple arithmetic" and I don't mean that) By arithmetic, it is meant any expression involving plus, minus, times, divide. Arithmetic excludes the possibility of infinite series, infinite sequences, min and max over infinite sets, limits, etc. so no sine, cosine, lim sup lim inf, integrals or analysis. Basically, arithmetic is of the same strength as first-order logic, while analysis requires second-order logic (i.e. requires the algebra of infinity). |
Regarding this comment:
The meta-goal is to fix this, so that it would be equivalent. The only reason that it is not equivalent is, as far as I can tell, is because |
@vsbogd writes:
Bingo! Yes, exactly!
Because this doesn't solve the main issue. Instead, it introduces a bunch of new atom types that are almost the same as some other atom types, but just slightly different. This is bad for multiple reasons:
Those are the reasons I dislike BoolValue. |
@ngeiswei writes:
Yes, we should. However, this is extremely difficult, and requires a major deep dive and restructuring of the pattern matcher. I tried doing this maybe a year ago or two, and after a long week, I failed. I kept the branch, pushed it to github somewhere in my repo, in case I wanted to try again.(here: https://github.com/linas/atomspace/tree/absent-link-rework ) There are multiple existing issues to cover this already. #215 -- #217 -- #1596 -- #1882 |
Per discussion in opencog#2004 this should help PLN.
This particular subtask seemed to be so straight-forward, that I simply just coded it up. It's here: pull req #2015 -- please review. I think it is more-or-less "complete". it can probably be extended to distributional TV's as well, or more generic values, but for now, its just for ordinary TV's, |
The problem is that in the Simple TV code "strength" may either correspond to a probability or a fuzzy value. But I would argue that even in the case of a probability the term "mean" is misleading. Does it mean the mean frequency of an occurrence of some positive event? Does it is mean the actually probability estimate of that positive event? Current it is implemented as the former, which is different than the later, as the actual probability estimate requires a prior (typically a Beta distribution with a Jeffrey or Bayesian prior), and the mean as currently implemented is actually the mode of the second order distribution. Hopefully the Distributional Value will clarify the terminology, first by removing the confusion between fuzzy and probability, and second by presenting the estimates, mean, mode, standard deviation, etc, as obtained from second order distributions. |
Closing. This was an interesting bu indeterminate conversation. The meta-issue was how to optimize the pattern engine for crsip true-false values, and pull req #2663 takes a step in that direction. |
Proposal for a significant change in inner workings of pattern matcher and related subsystems.
Proposal: introduce a special binary true/false value on all atoms.
Why?
How?
sizeof(Atom)
is unaffected.class:Atom
a new method with signature ofbool TFValueOf(void) const
to access this bit.AndLink
,OrLink
,NotLink
etc. will callTFValueOf()
when needed, to compute a crisp T/F for their outgoing set.OK, that's real easy, so far. Now the hard part. The stuff below is more controversial, and might have un-intended consequences:
GroundedPredicateNode
to expect a bool return value, instead of a TV. This will hit a lot of code and examples. (It will simplify them, and make them easier to understand!)GroundedPredicateNode
to always pass theEvaluationLink
that its wrapped with, as the first argument to every python/scheme/haskell callback. This will allow the python/scheme/haskell callback to access the Values of theEvaluationLink
, thus solving at least some of the problems debated in issue Better interoperability with deep learning frameworks #1970 and Add value to keep pointer to the python object #1971. This will hit a lot of code, since GPN is used everywhere. Maybe we need a NewGPN to maintain backwards-compat.cog-evalutate!
to return binary 0/1 as hinted in Return ValuePtr from EvaluationLink::do_evaluate() #1996Since changing
cog-evaluate!
will screw up some existing code, propose two new atom types.ValueOfLink
atom, see https://github.com/opencog/atomspace/blob/master/examples/atomspace/stream.scm for example.TruthValueOfLink
atom, to return the usual TVTFValueOfLink
to return the binary T/F. I will return a SimpleTruthValue with strength of 0.0 or 1.0 and confidence of 1.0. i.eTruthValue::TRUE_TV()
andTruthValue::FALSE_TV()
which are singletons, so we don't waste RAM.Maybe-bonus that maybe I should NOT mention here, but ah what the heck:
TruthValueOfLink
to work withPlusLink
,TimesLink
, etc. This will enable arithmetic in the AtomSpace. Since all PLN TV formulas are simple arithmetic, this will allow PLN tv formulas to be stored in the atomspace, This has one short-term benefit, and one long-term benefit:Short-term: Performance. There is a HUGE overhead to get in and out of scheme/python; its about 50 microseconds, which is crazy for arithmetic. Using TimesLink, etc will give a big performance boost.
Long-term: By placing the PLN formulas in the atomspace itself, the formulas could be reasoned about. Or even learned. For example, MOSES could try to find optimal formulas for PLN to use. Some deep-learning net could do the same. It will be a while before we could actually do this, but at least it now would be possible. Its not possible, as long as the formulas are buried in black-box
GroundedPredicateNodes
(or wherever PL:N is keeping them).The text was updated successfully, but these errors were encountered: