SHOGUN
v1.1.0
|
00001 /* 00002 * Copyright (c) 2009 Yahoo! Inc. All rights reserved. The copyrights 00003 * embodied in the content of this file are licensed under the BSD 00004 * (revised) open source license. 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 3 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * Written (W) 2011 Shashwat Lal Das 00012 * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society. 00013 */ 00014 00015 #include <shogun/classifier/vw/vw_example.h> 00016 00017 using namespace shogun; 00018 00019 VwExample::VwExample(): tag(), indices(), atomics(), 00020 num_features(0), pass(0), 00021 final_prediction(0.), loss(0), 00022 eta_round(0.), global_weight(0), 00023 example_t(0), total_sum_feat_sq(1), sorted(false) 00024 { 00025 ld = new VwLabel(); 00026 } 00027 00028 VwExample::~VwExample() 00029 { 00030 if (ld) 00031 delete ld; 00032 if (tag.end_array != tag.begin) 00033 { 00034 SG_FREE(tag.begin); 00035 tag.end_array = tag.begin; 00036 } 00037 00038 for (vw_size_t j = 0; j < 256; j++) 00039 { 00040 if (atomics[j].begin != atomics[j].end_array) 00041 SG_FREE(atomics[j].begin); 00042 } 00043 SG_FREE(indices.begin); 00044 } 00045 00046 void VwExample::reset_members() 00047 { 00048 num_features = 0; 00049 total_sum_feat_sq = 1; 00050 example_counter = 0; 00051 global_weight = 0; 00052 example_t = 0; 00053 eta_round = 0; 00054 final_prediction = 0; 00055 loss = 0; 00056 00057 for (vw_size_t* i = indices.begin; i != indices.end; i++) 00058 { 00059 atomics[*i].erase(); 00060 sum_feat_sq[*i]=0; 00061 } 00062 00063 indices.erase(); 00064 tag.erase(); 00065 }