44 for (
vw_size_t i = 0; i < num_threads; i++)
72 for (
vw_size_t i = 0; i < num_threads; i++)
78 for (
vw_size_t j = 0; j < length/num_threads; j++)
96 int32_t f = io_temp.
open_file(reg_name,
'w');
99 SG_SERROR(
"Can't open: %s for writing! Exiting.\n", reg_name)
107 io_temp.
write_file((
char*)&v_length,
sizeof(v_length));
120 io_temp.
write_file((
char *)&len,
sizeof(len));
135 len = sprintf(buff,
"Version %s\n", vw_version);
144 len = sprintf(buff,
"\n");
148 len = sprintf(buff,
"ngram:%d skips:%d\nindex:weight pairs:\n", (int32_t)
env->
ngram, (int32_t)
env->
skips);
157 for(uint32_t i = 0; i < length; i++)
171 int32_t len = sprintf(buff,
"%d:%f\n", i, v);
184 int32_t fd = source.
open_file(file,
'r');
187 SG_SERROR(
"Unable to open file for loading regressor!\n")
191 source.
read_file((
char*)&v_length,
sizeof(v_length));
192 char* t = SG_MALLOC(
char, v_length);
197 SG_SERROR(
"Regressor source has an incompatible VW version!\n")
207 source.
read_file((
char *)&local_num_bits,
sizeof(local_num_bits));
210 SG_SERROR(
"Wrong number of bits in regressor source!\n")
215 source.
read_file((
char*)&local_thread_bits,
sizeof(local_thread_bits));
220 source.
read_file((
char *)&len,
sizeof(len));
224 for (; len > 0; len--)
240 source.
read_file((
char*)&local_ngram,
sizeof(local_ngram));
242 source.
read_file((
char*)&local_skips,
sizeof(local_skips));
252 ssize_t hash_bytes = source.
read_file((
char *)&hash,
sizeof(hash));
258 if (weight_bytes <= 0)
264 =
weight_vectors[hash % num_threads][(hash*stride)/num_threads] + w;
uint32_t vw_size_t
vw_size_t typedef to work across platforms
T get_element(int32_t index) const
bool random_weights
Whether to use random weights.
virtual void load_regressor(char *file_name)
virtual void init(CVwEnvironment *env_to_use=NULL)
Class CVwEnvironment is the environment used by VW.
CLossFunction * loss
Loss function.
float64_t min_label
Smallest label seen.
float32_t ** weight_vectors
Weight vectors, one array for each thread.
vw_size_t num_bits
log_2 of the number of features
int32_t get_num_elements() const
virtual bool close_file()
float64_t max_label
Largest label seen.
virtual ssize_t write_file(const void *buf, size_t nbytes)
Class SGObject is the base class of all shogun objects.
void push_back(T element)
vw_size_t ngram
ngrams to generate
DynArray< char * > pairs
Pairs of features to cross for quadratic updates.
vw_size_t stride
Number of elements in weight vector per feature.
vw_size_t skips
Skips in ngrams.
virtual int open_file(const char *name, char flag='r')
virtual ssize_t read_file(void *buf, size_t nbytes)
CSquaredLoss implements the squared loss function.
all of classes and functions are contained in the shogun namespace
vw_size_t thread_bits
log_2 of the number of threads
float32_t initial_weight
Initial value of all elements in weight vector.
const char * vw_version
VW version.
CVwEnvironment * env
Environment.
vw_size_t thread_mask
Mask used by regressor for learning.
bool adaptive
Whether adaptive learning is used.
virtual void dump_regressor(char *reg_name, bool as_text)
vw_size_t v_length
Length of version string.