Skip to content

[WIP] Refactor multiclass#2

Open
LiuYuHui wants to merge 5 commits into
shogun-toolbox:masterfrom
LiuYuHui:multiclass
Open

[WIP] Refactor multiclass#2
LiuYuHui wants to merge 5 commits into
shogun-toolbox:masterfrom
LiuYuHui:multiclass

Conversation

@LiuYuHui

@LiuYuHui LiuYuHui commented Jul 15, 2020

Copy link
Copy Markdown
Contributor
  • find constructor involving in labels, rewrite parameter and body.
  • find method involving in labels, rewrite parameter and body.
  • when find CXXCtorInitializer involving labels, remove the labels.
  • when find set_labels in CXXMethod, remove it.

@gf712

gf712 commented Jul 15, 2020

Copy link
Copy Markdown
Member

You are probably compiling with an old include file and linking to the new lib (or vice versa). Can you share the CMakeCache.txt please?

@LiuYuHui

Copy link
Copy Markdown
Contributor Author

You are probably compiling with an old include file and linking to the new lib (or vice versa). Can you share the CMakeCache.txt please?

hi @gf712 , here is the CMakeCache.txt: https://pastebin.com/1wBzQBnY

@LiuYuHui

LiuYuHui commented Jul 17, 2020

Copy link
Copy Markdown
Contributor Author

Current LibTooling script support rewrite CXXMethodDecl and CXXConstructorDecl.
before

class Test : public MulticlassMachine{
public:
    Test();
    Test(std::shared_ptr<Labels> labs, int C): MulticlassMachine(labs){
        set_labels(labs);
    }

    void train_machine(std::shared_ptr<Features> data) override{
        auto t = m_labels;
    }

    void test2(){
        set_labels(m_labels);
        auto t = m_labels;
    }

     void test3(const std::shared_ptr<Features>& feature){
        set_labels(m_labels);
        auto t = m_labels;
    }
};

after

class Test : public MulticlassMachine{
public:
    Test();
    Test( int C): MulticlassMachine(labs){
        set_labels(labs);
    }

    void train_machine(std::shared_ptr<Features> data, const std::shared_ptr<Labels>& labs) override{
        auto t = labs;
    }

    void test2(const std::shared_ptr<Labels>& labs){
        set_labels(labs);
        auto t = labs;
    }

     void test3(const std::shared_ptr<Features>& feature, const std::shared_ptr<Labels>& labs){
        set_labels(labs);
        auto t = labs;
    }
};

@LiuYuHui

LiuYuHui commented Jul 21, 2020

Copy link
Copy Markdown
Contributor Author

i think the only missing one is that CXXCtorInitializer.
such as

MulticlassSVM::MulticlassSVM(
	std::shared_ptr<MulticlassStrategy >strategy, float64_t C, std::shared_ptr<Kernel> k, std::shared_ptr<Labels> lab)
	: KernelMulticlassMachine(std::move(strategy), k, std::make_shared<SVM>(C, k, lab), lab)
{
	init();
	m_C=C;
}

when we remove std::shared_ptr<Labels> lab from MulticlassSVM::MulticlassSVM, we should also change the constructor initializer to KernelMulticlassMachine(std::move(strategy), k, std::make_shared<SVM>(C, k, lab))

@gf712

gf712 commented Jul 21, 2020

Copy link
Copy Markdown
Member

i think the only missing one is that CXXCtorInitializer.
such as

MulticlassSVM::MulticlassSVM(
	std::shared_ptr<MulticlassStrategy >strategy, float64_t C, std::shared_ptr<Kernel> k, std::shared_ptr<Labels> lab)
	: KernelMulticlassMachine(std::move(strategy), k, std::make_shared<SVM>(C, k, lab), lab)
{
	init();
	m_C=C;
}

when we remove std::shared_ptr<Labels> lab from MulticlassSVM::MulticlassSVM, we should also change the constructor initializer to KernelMulticlassMachine(std::move(strategy), k, std::make_shared<SVM>(C, k, lab))

Cool! Do you need help with that? :)

@LiuYuHui

LiuYuHui commented Jul 21, 2020

Copy link
Copy Markdown
Contributor Author

i think the only missing one is that CXXCtorInitializer.
such as

MulticlassSVM::MulticlassSVM(
	std::shared_ptr<MulticlassStrategy >strategy, float64_t C, std::shared_ptr<Kernel> k, std::shared_ptr<Labels> lab)
	: KernelMulticlassMachine(std::move(strategy), k, std::make_shared<SVM>(C, k, lab), lab)
{
	init();
	m_C=C;
}

when we remove std::shared_ptr<Labels> lab from MulticlassSVM::MulticlassSVM, we should also change the constructor initializer to KernelMulticlassMachine(std::move(strategy), k, std::make_shared<SVM>(C, k, lab))

Cool! Do you need help with that? :)

yes, I have no idea about how to remove the label in constructor initializer. i find a function call getInit () in clang reference, but i don't know how to use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants