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
2 changed files
with
57 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include <shogun/multiclass/ecoc/ECOCLLBDecoder.h> | ||
|
||
using namespace shogun; | ||
|
||
float64_t CECOCLLBDecoder::compute_distance(SGVector<float64_t> outputs, const int32_t *code) | ||
{ | ||
float64_t loss = 0; | ||
for (int32_t i=0; i < outputs.vlen; ++i) | ||
loss += outputs[i]*code[i]; | ||
return -loss; | ||
} |
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,46 @@ | ||
/* | ||
* 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. | ||
* | ||
* Written (W) 2012 Chiyuan Zhang | ||
* Copyright (C) 2012 Chiyuan Zhang | ||
*/ | ||
|
||
#ifndef ECOCLLBDECODER_H__ | ||
#define ECOCLLBDECODER_H__ | ||
|
||
#include <shogun/multiclass/ecoc/ECOCSimpleDecoder.h> | ||
|
||
namespace shogun | ||
{ | ||
|
||
/** Margin Loss based decoder. | ||
* Using OVREncoder with this Decoder should be equivlalent to | ||
* traditional OVR Strategy. | ||
*/ | ||
class CECOCLLBDecoder: public CECOCSimpleDecoder | ||
{ | ||
public: | ||
/** constructor */ | ||
CECOCLLBDecoder() {} | ||
|
||
/** destructor */ | ||
virtual ~CECOCLLBDecoder() {} | ||
|
||
/** get name */ | ||
virtual const char* get_name() const { return "ECOCLLBDecoder"; } | ||
|
||
protected: | ||
/** whether to turn the output into binary before decoding */ | ||
virtual bool binary_decoding() { return false; } | ||
|
||
/** compute distance */ | ||
virtual float64_t compute_distance(SGVector<float64_t> outputs, const int32_t *code)=0; | ||
}; | ||
|
||
} /* shogun */ | ||
|
||
#endif /* end of include guard: ECOCLLBDECODER_H__ */ | ||
|