clean up warnings from msvc

This commit is contained in:
Tianqi Chen
2014-08-25 11:01:21 -07:00
parent 4f0b0d2c88
commit ca0b008fb0
20 changed files with 217 additions and 46 deletions

View File

@@ -60,7 +60,7 @@ class GBLinear : public IGradBooster<FMatrix> {
}
}
// remove bias effect
double dw = param.learning_rate * param.CalcDeltaBias(sum_grad, sum_hess, model.bias()[gid]);
bst_float dw = static_cast<bst_float>(param.learning_rate * param.CalcDeltaBias(sum_grad, sum_hess, model.bias()[gid]));
model.bias()[gid] += dw;
// update grad value
#pragma omp parallel for schedule(static)
@@ -86,7 +86,7 @@ class GBLinear : public IGradBooster<FMatrix> {
sum_hess += p.hess * v * v;
}
float &w = model[fid][gid];
double dw = param.learning_rate * param.CalcDelta(sum_grad, sum_hess, w);
bst_float dw = static_cast<bst_float>(param.learning_rate * param.CalcDelta(sum_grad, sum_hess, w));
w += dw;
// update grad value
for (typename FMatrix::ColIter it = fmat.GetSortedCol(fid); it.Next();) {

View File

@@ -134,7 +134,7 @@ class GBTree : public IGradBooster<FMatrix> {
for (unsigned i = 0; i < nsize; ++i) {
const int tid = omp_get_thread_num();
tree::RegTree::FVec &feats = thread_temp[tid];
const size_t ridx = batch.base_rowid + i;
int64_t ridx = static_cast<int64_t>(batch.base_rowid + i);
const unsigned root_idx = info.GetRoot(ridx);
// loop over output groups
for (int gid = 0; gid < mparam.num_output_group; ++gid) {
@@ -172,15 +172,15 @@ class GBTree : public IGradBooster<FMatrix> {
}
updaters.clear();
std::string tval = tparam.updater_seq;
char *saveptr, *pstr;
pstr = strtok_r(&tval[0], ",", &saveptr);
char *pstr;
pstr = strtok(&tval[0], ",");
while (pstr != NULL) {
updaters.push_back(tree::CreateUpdater<FMatrix>(pstr));
for (size_t j = 0; j < cfg.size(); ++j) {
// set parameters
updaters.back()->SetParam(cfg[j].first.c_str(), cfg[j].second.c_str());
}
pstr = strtok_r(NULL, ",", &saveptr);
pstr = strtok(NULL, ",");
}
tparam.updater_initialized = 1;
}
@@ -218,7 +218,7 @@ class GBTree : public IGradBooster<FMatrix> {
tree::RegTree::FVec *p_feats) {
size_t itop = 0;
float psum = 0.0f;
const int bid = mparam.BufferOffset(buffer_index, bst_group);
const int64_t bid = mparam.BufferOffset(buffer_index, bst_group);
// load buffered results if any
if (bid >= 0) {
itop = pred_counter[bid];
@@ -320,7 +320,7 @@ class GBTree : public IGradBooster<FMatrix> {
* \brief get the buffer offset given a buffer index and group id
* \return calculated buffer offset
*/
inline size_t BufferOffset(int64_t buffer_index, int bst_group) const {
inline int64_t BufferOffset(int64_t buffer_index, int bst_group) const {
if (buffer_index < 0) return -1;
utils::Check(buffer_index < num_pbuffer, "buffer_index exceed num_pbuffer");
return buffer_index + num_pbuffer * bst_group;