- added one hot gen
git-svn-id: http://moon:8086/svn/software/trunk/projects/Rbm@841 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+22
-4
@@ -36,14 +36,32 @@ public:
|
||||
|
||||
arma::mat step_forward(arma::mat &state, const arma::mat &v);
|
||||
|
||||
arma::mat to_next(const arma::mat &v)
|
||||
arma::mat row_one_hot(size_t len, size_t index)
|
||||
{
|
||||
return v.cols(0, NUM_CODES-1);
|
||||
arma::mat data = arma::zeros(1, len);
|
||||
data[index] = 1;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
arma::mat to_next(const arma::mat &v, bool clamp=false)
|
||||
{
|
||||
arma::mat res = v.cols(0, NUM_CODES-1);
|
||||
if (clamp)
|
||||
{
|
||||
res = row_one_hot(res.n_cols, res.index_max());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
arma::mat to_curr(const arma::mat &v)
|
||||
arma::mat to_curr(const arma::mat &v, bool clamp=false)
|
||||
{
|
||||
return v.cols(NUM_CODES, 2*NUM_CODES-1);
|
||||
arma::mat res = v.cols(NUM_CODES, 2*NUM_CODES-1);
|
||||
if (clamp)
|
||||
{
|
||||
res = row_one_hot(res.n_cols, res.index_max());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void setParams(Rbm::Params const ¶m)
|
||||
|
||||
Reference in New Issue
Block a user