Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Copyright (C) 2012 Sergey Lisitsyn | ||
*/ | ||
|
||
#include <shogun/structure/DirectorRiskFunction.h> | ||
#include <shogun/structure/libbmrm.h> | ||
|
||
using namespace shogun; | ||
|
||
CDirectorRiskFunction::CDirectorRiskFunction() | ||
: CRiskFunction() | ||
{ | ||
} | ||
|
||
CDirectorRiskFunction::~CDirectorRiskFunction() | ||
{ | ||
} | ||
|
||
void CDirectorRiskFunction::risk(void* data, float64_t* R, float64_t* subgrad, float64_t* W) | ||
{ | ||
CDotFeatures* features = (CDotFeatures*)(((bmrm_data_T*)data)->X); | ||
CLabels* labels = (CLabels*)(((bmrm_data_T*)data)->y); | ||
int32_t w_dim = ((bmrm_data_T*)data)->w_dim; | ||
risk_directed(features,labels,SGVector<float64_t>(R,1,false), | ||
SGVector<float64_t>(subgrad,w_dim,false), | ||
SGVector<float64_t>(W,w_dim,false)); | ||
} | ||
|
||
void CDirectorRiskFunction::risk_directed(CDotFeatures* features, CLabels* labels, const SGVector<float64_t> R, | ||
const SGVector<float64_t> subgrad, const SGVector<float64_t> W) | ||
{ | ||
SG_NOTIMPLEMENTED; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Copyright (C) 2012 Sergey Lisitsyn | ||
*/ | ||
|
||
#ifndef DIRECTOR_RISK_FUNCTION_H_ | ||
#define DIRECTOR_RISK_FUNCTION_H_ | ||
|
||
#include <shogun/structure/RiskFunction.h> | ||
#include <shogun/features/DotFeatures.h> | ||
#include <shogun/labels/Labels.h> | ||
|
||
namespace shogun | ||
{ | ||
|
||
/** @brief Class CDirectorRiskFunction TODO | ||
* | ||
*/ | ||
class CDirectorRiskFunction : public CRiskFunction | ||
{ | ||
public: | ||
/** default constructor */ | ||
CDirectorRiskFunction(); | ||
|
||
/** destructor */ | ||
virtual ~CDirectorRiskFunction(); | ||
|
||
/** computes the value of the risk function and sub-gradient at given point | ||
* | ||
*/ | ||
virtual void risk(void* data, float64_t* R, float64_t* subgrad, float64_t* W); | ||
|
||
/** computes the value of the risk function and sub-gradient at given point | ||
* director interface | ||
*/ | ||
virtual void risk_directed(CDotFeatures* features, CLabels* labels, const SGVector<float64_t> R, | ||
const SGVector<float64_t> subgrad, const SGVector<float64_t> W); | ||
|
||
/** @return name of SGSerializable */ | ||
virtual const char* get_name() const { return "DirectorRiskFunction"; } | ||
|
||
}; /* CDirectorRiskFunction */ | ||
} | ||
#endif /* DIRECTOR_RISK_FUNCTION_H_ */ |