-
Notifications
You must be signed in to change notification settings - Fork 6
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
GroundedObjectNode is desirable #43
Comments
It makes sense, I have no objection. @Necr0x0Der I think you should duplicate that issue in |
@ngeiswei , I'm starting to think that it would be easier right now to avoid introducing new GroundedObjectNode type. What we mostly need now is to run object methods from URE/BC as formulas for rules. If we have something like
then, we will need to extend URE to deal with formulas implemented in GroundedObjectNodes, because it extracts premises from formula arguments, etc. It's not a big deal, but still requires some changes. |
Oh, I'm confused, I think I might have misunderstood the purpose of So you do mean that |
yes |
BTW, we could have some gsnA = GroundedSchemaNode("gsnA", lambda x : mm.nn.submodule.forward(x)) # call forward on mm.nn.submodule
eolA = ExecutionOutputLink(gsnA, ListLink(ConceptNode("aa"), ConceptNode("bb")))
execute_atom(a, eolA) == ConceptNode("bb")
gsnB = GroundedSchemaNode("gsnA", lambda x : nn.forward(x)) # call forward on nn
eolB = ExecutionOutputLink(gsnB, ListLink(ConceptNode("aa"), ConceptNode("bb")))
execute_atom(a, eolB) == ConceptNode("aa"), In example above the code which will be executed is not encoded in |
@vsbogd , how do you suppose GroundedSchemaNode will accept a python lambda function as input? It doesn't do this. It accesses functions by names. Again, we can do something similar to setLocalFuncion for python functions, so it will assign an Atomese name for a function, which will be stored in LibraryManager as PyObject*. But this would be the same as proposed for "obj:", but without access to all class methods... |
@vsbogd, you mean Also I don't understand |
@vsbogd in case you meant to represent a record of mapping from inputs to outputs, don't forget that |
Actually I found that my idea is very similar to manual functions registration which were implemented by Alexey some time ago. And it obviously doesn't work in case of atom serialization/deserialization. So it is not very useful. |
I didn't keep in mind that keeping function names as strings in |
The other option would be to have the constructor turn the python code into actual atomese code (using |
I'm afraid Atomese is far from being expressive enough for this (not to mention efficiency issues and capabilities to process values and data structure). |
Well, it seems we do have a use case for GroundedObjectNode besides accessing its methods via ExecutionOutputLink or EvaluationLink. Namely, it would be convenient for us to pass GroundedObjects (e.g. tensors) to GroundedSchemas. Since we need to avoid converting pytorch tensors into FloatValues to maintain a differentiable computational graph, we either need a PointerValue to pass between grounded schemas, or to pass GroundedObjects which are connected to PyObject*... So, we are thinking again about implementing GroundedObjectNodes... |
Added new issue in opencog's repo opencog#1970 describing our usecases |
We would like to continue the discussion on
2a) Accessing GON methods. The question is: is it better to reuse
or even without additional DotLink
Unfortunately, DotLink cannot return a GroundedSchemaNode pointing to the selected method without refactoring GroundedSchemaNode (e.g. without removing LibraryManager and storing pointers to functions inside GSN). Also, if we are accessing not methods, but fields, DotLink shouldn't return an Atom... So, the approach with DotLink needs more elaboration, although it might be very useful in terms of making "declarative API" to foreign atoms.
Benefits of this approach is that it can be implemented without touching 2b) If we don't reuse @ngeiswei , @vsbogd , @noskill , @pennachin any comment or insight is welcome |
Thanks for the clear presentation. It seems to me
I like I can't really find any that should be discarded outright, so I would say go with what you think is best. |
@ngeiswei, as far as I understand second part of 2.a also requires changes in URE, because I like 2.b and
|
I have tried to create custom Now it is possible to create own Few facts about current implementation:
|
I am going to implement |
I see, so apparently you don't even need to touch |
Yes, Alexey and Anatoly have prepared first prototype version already. |
Yes, my sketch is here: |
Couple of obstacles so far: (1) When atom is added into atomspace it is copied and copying procedure for nodes copies only node type and name which means that any other state will be lost. Possible solutions are: |
@ngeiswei , @pennachin , what is your opinion? Is it better to use hacky |
(2)
|
issue (2) is not actual anymore as there is PR to issue (1), I have implemented option (b) in my branch of Current result can be seen in my branch. I am going to discuss and improve API further and then raise PR to |
Implementation is done, closing it |
This issue is closely related to #42 , but is a separate and more controversial one. The idea is to implement a support for GroundedObjectNodes in addition to GroundedPredicate/Schema nodes. The idea comes from the necessity to access (e.g. python) objects from schema nodes grounded in methods of other objects, and these methods can accepts these objects as arguments, so names of references to these objects can change, so referring to objects by their (python) names is much worse than referring to functions by their names. Thus, grounded objects should be accessed by their Atomese names or as Atoms. For example, C++ API for GroundedSchemas uses
LibraryManager
withsetLocalFunc
, which associates the given name with the pointer to the function, so it can be accessed from anywhere by this name (while PythonEval retrieves PyObject* pointer to the function each time by its Python name).Implementing GroundedObjectNodes, which either store pointers to the grounding objects inside them or in a sort of global LibraryManager, seems to be a convenient (although not absolutely necessary) way to handle certain use cases like Neural Module Networks implemented as a set of (possibly dynamically created) objects, and can have other use cases.
The first questions is, are there objections against implementing GroundedObjectNode (like "this functionality should be implemented in the target language using existing API" or whatever)?
The text was updated successfully, but these errors were encountered: