CompactVMatrix.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00047
#ifndef CompactCompactVMatrix_INC
00048
#define CompactCompactVMatrix_INC
00049
00050
#include "RowBufferedVMatrix.h"
00051
#include "VMat.h"
00052
00053
namespace PLearn {
00054
using namespace std;
00055
00063 class CompactVMatrix :
public RowBufferedVMatrix
00064 {
00065 typedef RowBufferedVMatrix inherited;
00066
class SDBVMatrix;
00067
00068
protected:
00069
00071 Storage<unsigned char> data;
00072 int row_n_bytes;
00073 int n_bits;
00074 int n_symbols;
00075 int n_fixedpoint;
00076 int n_variables;
00077 bool one_hot_encoding;
00078
public:
00079 TVec<int> n_symbol_values;
00080 int nbits() {
return n_bits; }
00081 int nsymbols() {
return n_symbols; }
00082 int nfixedpoint() {
return n_fixedpoint; }
00083
protected:
00084 Vec fixedpoint_min,
fixedpoint_max;
00085 Vec delta;
00086 TVec<int> variables_permutation;
00087
00091
static unsigned char n_bits_in_byte[256];
00092
static void set_n_bits_in_byte();
00093
00094
public:
00095 int n_last;
00096
protected:
00097 int normal_width;
00098
public:
00099
void setOneHotMode(
bool on=
true);
00100
00101
00102
00103
00104
CompactVMatrix();
00105
00106
CompactVMatrix(
int the_length,
int n_variables,
int n_binary,
int n_nonbinary_discrete,
00107
int n_fixed_point,
TVec<int>& n_symbolvalues,
Vec& fixed_point_min,
00108
Vec& fixed_point_max,
bool one_hot_encoding=
true);
00109
00122
CompactVMatrix(
VMat m,
int keep_last_variables_last=1,
bool onehot_encoding=
true);
00123
00125
00126
CompactVMatrix(
const string& filename,
int nlast=1);
00127
00134
CompactVMatrix(
CompactVMatrix* cvm,
VMat m,
bool rescale=
false,
bool check=
true);
00135
00137
void append(
CompactVMatrix* vm);
00138
00150
void perturb(
int i,
Vec row,
real noise_level,
int n_last);
00151
00156 TVec<int>&
permutation_vector() {
return variables_permutation; }
00157
00158
protected:
00159
00161
virtual void getNewRow(
int i,
const Vec& v)
const;
00162
00163
public:
00164
00166
00168
virtual real squareDifference(
int i,
int j);
00169
00171
virtual real dotProduct(
int i,
int j)
const;
00172
00173
virtual real dot(
int i1,
int i2,
int inputsize)
const;
00174
virtual real dot(
int i,
const Vec& v)
const;
00175
00176
00178
virtual void encodeAndPutRow(
int i,
Vec v);
00181
virtual void putRow(
int i,
Vec v);
00182
virtual void putSubRow(
int i,
int j,
Vec v);
00183
00185 virtual void save(
const string& filename)
00186 { Object::save(filename); }
00187
00188
00190
00191
00192
PLEARN_DECLARE_OBJECT(
CompactVMatrix);
00193
void makeDeepCopyFromShallowCopy(map<const void*, void*>& copies);
00194 virtual void build() {}
00195
00196
protected:
00198 int symbols_offset;
00199 int fixedpoint_offset;
00200 Vec row_norms;
00201 };
00202
00203
DECLARE_OBJECT_PTR(
CompactVMatrix);
00204
00205 }
00206
#endif
Generated on Tue Aug 17 15:49:29 2004 for PLearn by
1.3.7