Open cesarsouza opened 7 years ago
FindAllWithName C# API find all functions with the specified name. It is not the sample as python find_all_with_name. Here a and b are input variables. To find them, you may do this: var inputs = c.Inputs.Where(i => i.Name == "i");
Hi @liqunfu
Many thanks for the answer! Indeed, using c.Inputs.Where
instead of FindAllWithName does the trick and retrieves the variables named "i" in the example above.
However, wasn't FindAllWithName supposed to do the same? If not, why? Having two methods with almost the same name in the Python and C# APIs with different behaviors is quite confusing. Is there any documentation for the FindAllWithName method at this moment?
Regards, Cesar
The C++ API behaves the same - returns only functions of the given name. It is mainly because C#/C++ are strong typed. To mix Functions with Variables is not desirable in C#. I am curious to know an use case where the python behavior is necessary in C#.
Hi @liqunfu,
Thanks for the answer. It is not a matter of being necessary, but a mater of being consistent. If it is assumed that it should be the best for CNTK to have inconsistent behaviors across APIs, then that's also fine. However, those inconsistencies should be thorough mentioned across the documentation because it is very likely that there will be many users coming from Python to C# who might end up bumping into this issue (the fact that #2418 had been also been raised by another independent developer illustrates this).
Thanks again, Cesar
@liqunfu: You asked for a use case. This would be very helpful for something like word2vec, where the desired embedding matrix is located inside a larger model. I'd like to be able to extract the matrix by name after training is complete. Since FindByName can't locate it, I have to store it a global variable when I create it in order to find it later.
Hi there,
This is a direct translation of the Python code at https://www.cntk.ai/pythondocs/cntk.ops.functions.html#cntk.ops.functions.Function.find_all_with_name
In the C#/.NET API,
results.Count
is zero, while in the Python API,len(c.find_all_with_name('i'))
is 2.