-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Created CUAIFile class (Issue #1913) to save and load file in UAI file format. #2019
Conversation
CUAIFile implemented according to Issue #1913 |
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Written (W) 2014 Abinash Panda (gsomix) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you want to name after gsomix :)
@abinashpanda Good job! There are several issues, you may try to resolve. Make sure that function tables in UAI format are actually energy tables in our case. Please add unit-tests for the new class. |
Also, please git reset --soft to make only one commit for this PR. |
#include <shogun/io/UAIFile.h> | ||
|
||
#include <shogun/lib/SGVector.h> | ||
#include <shogun/base/DynArray.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use shogun/lib/DynamicArray.h
parse() is great! But I think you missed how to construct a FactorGraph from the UAI file. Please think about how to do that. Something like SGVector::load(CFile*). |
|
||
void CUAIFile::parse() | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why new line?
any progress on this PR? |
@vigsterkr I would be completing it by today. I was busy with my GSoC applications and class test. |
@hushell @vigsterkr I have corrupted this PR with many commits and I have to still refactor it. So should I close this one and send a new PR? |
@abinashpanda corrupted how? |
m_tokenizer=NULL; | ||
m_line_tokenizer=NULL; | ||
m_parser=NULL; | ||
m_line_reader=NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SG_ADD
is still missing... please check other shogun class implementation...
@vigsterkr by corrupted means, I have messed up the implementation. Regarding SG_ADD: I am trying to implement this class as CSVFile has been implemented. I didn't find any SG_ADD. I you could suggest me some other class. |
@abinashpanda Please don't launch another PR, since we have already discussed a lot on this one. Try to git reset --soft. This way people knows better what's going on here. |
virtual void get_vector(uint16_t*& vector, int32_t& len); | ||
virtual void get_vector(int64_t*& vector, int32_t& len); | ||
virtual void get_vector(uint64_t*& vector, int32_t& len); | ||
//@} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we try to use function templates here? IMO it whould really reduce the amount of duplicated code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tklein23 see CFile.h
Code itself looks good to me. I'm happy to see unit-tests for that. But I'm really confused about 1000 lines for reading one file format. (@abinashpanda - I know it's not completely your fault, but it's a good time to discuss this.) The header file contains about 450 lines, the implementation 350. Seems to be 90% boiler-plate-code. Is this really necessary or did we just massively duplicate code? Any suggestions how to improve it? Any objections against using function templates to reduce the size of the header file? Shouldn't be a big deal - let me know if you need any assistance (i.e. documentation/examples) for this. |
@tklein23 By the function template implementation for
|
I'm convinced that it requires bigger changes. I'd say it's beyond the scope of this issue. @hushell - as you created the issue, finishing this issue is up to you. Please check if we're done here. |
@tklein23 I think since most of file loaders in Shogun are implemented in this way, we can keep it as this temporally. My intuition was not to make so much effort to create a UAI file loader. @abinashpanda The code for UAI format part is good. Please fix the Travis issues, try to avoid using add_vector() to register members. I mean you don't need to stick on SGVector. Once you make Travis happy, we could merge this PR for you. However, it seems you only finished 50% of issue #1913, we would like to use these code to build factor graphs. Well, since this PR has lived for a long time, let's finish it soon and start a new one for the rest of the task. |
|
||
/** Can only be enable after this issue is https://github.com/shogun-toolbox/shogun/issues/1972 | ||
* resolved | ||
* SG_ADD(m_factors_table, "m_factors_table", "table of factors", MS_NOT_AVAILABLE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, in this way, it passed the clone tests. Use "factors_table" not "m_factors_table".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Sunday 30 March 2014 00:52:18 Shell Hu wrote:
+}
+
+CUAIFile::~CUAIFile()
+{
- SG_UNREF(m_tokenizer);
- SG_UNREF(m_line_tokenizer);
- SG_UNREF(m_parser);
- SG_UNREF(m_line_reader);
+}
+void CUAIFile::init()
+{
+
- /** Can only be enable after this issue is
Adding support forSGVector
to Parameter::add_vector #1972 + * resolved MS_NOT_AVAILABLE);\* SG_ADD(m_factors_table, "m_factors_table", "table of factors",
Interesting, in this way, it passed the clone tests. Use "factors_table" not
"m_factors_table".
No surprise: No registration takes place, so it's simply serializing an
object without members.
If we're only missing support for SGVector
, can't we just enable all
other members and keep the affected ones disabled until #1972 is solved?
It seems Travis issues have been solved, I am not sure we still have problems related to #1972. |
namespace shogun | ||
{ | ||
|
||
/** @brief Class UAIFILE used to read data from comma-separated values (CSV) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this class description is not true at all..
@abinashpanda - welcome back. I hope you are fully recovered. What's the status of this PR? Last Travis built failed because SerializationXML.UAIFile is broken. Do you know what happened here? |
@tklein23 - I am fully recovered now. |
@abinashpanda let's wrap this up. After getting over the serialization issue, you could choose to leave the 2nd half of the entrance task aside, i.e., no touching with factor graph stuffs. It will be nice to get familiar with SSVM solvers in Shogun in pre-GSoC period. |
I suggest you copy the unit test template and fill in your class that fails by hand, have this as a separate Shogun program and then debug to see whats wrong. Let me know if that helps, sometimes this stuff is tricky |
SG_UNREF(m_parser); | ||
SG_UNREF(m_line_reader); | ||
|
||
delete [] m_factors_table; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SG_FREE is better. I mean use SG_ALLOC and SG_FREE.
@abinashpanda Almost here! Great job! Just two things: 1) merge all commits to a single one, by using git reset --soft; 2) Make sure valgrind reports no memory leaks: valgrind --leak-check=full ./shogun-unit-test --gtest_filter=UAIFileTest* |
Ran valgrind test and no memory leaks found. |
@abinashpanda - Congratulations. Let's wait for Travis and @hushell to merge. ;) |
@tklein23 It looks great for me! Please merge for Abinash. |
Created CUAIFile class (Issue #1913) to save and load file in UAI file format.
No description provided.