Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
cbc56c74
Commit
cbc56c74
authored
Dec 18, 2016
by
Guolin Ke
Browse files
fix bug in set_query
parent
64db9578
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
7 deletions
+8
-7
include/LightGBM/dataset.h
include/LightGBM/dataset.h
+1
-1
src/io/dataset.cpp
src/io/dataset.cpp
+1
-1
src/io/metadata.cpp
src/io/metadata.cpp
+6
-5
No files found.
include/LightGBM/dataset.h
View file @
cbc56c74
...
...
@@ -88,7 +88,7 @@ public:
void
SetWeights
(
const
float
*
weights
,
data_size_t
len
);
void
SetQuery
Boundaries
(
const
data_size_t
*
query
_boundaries
,
data_size_t
len
);
void
SetQuery
(
const
data_size_t
*
query
,
data_size_t
len
);
void
SetQueryId
(
const
data_size_t
*
query_id
,
data_size_t
len
);
...
...
src/io/dataset.cpp
View file @
cbc56c74
...
...
@@ -91,7 +91,7 @@ bool Dataset::SetIntField(const char* field_name, const int* field_data, data_si
std
::
string
name
(
field_name
);
name
=
Common
::
Trim
(
name
);
if
(
name
==
std
::
string
(
"query"
)
||
name
==
std
::
string
(
"group"
))
{
metadata_
.
SetQuery
Boundaries
(
field_data
,
num_element
);
metadata_
.
SetQuery
(
field_data
,
num_element
);
}
else
if
(
name
==
std
::
string
(
"query_id"
)
||
name
==
std
::
string
(
"group_id"
))
{
metadata_
.
SetQueryId
(
field_data
,
num_element
);
}
else
{
...
...
src/io/metadata.cpp
View file @
cbc56c74
...
...
@@ -312,26 +312,27 @@ void Metadata::SetWeights(const float* weights, data_size_t len) {
LoadQueryWeights
();
}
void
Metadata
::
SetQuery
Boundaries
(
const
data_size_t
*
query
_boundaries
,
data_size_t
len
)
{
void
Metadata
::
SetQuery
(
const
data_size_t
*
query
,
data_size_t
len
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutex_
);
// save to nullptr
if
(
query
_boundaries
==
nullptr
||
len
==
0
)
{
if
(
query
==
nullptr
||
len
==
0
)
{
query_boundaries_
.
clear
();
num_queries_
=
0
;
return
;
}
data_size_t
sum
=
0
;
for
(
data_size_t
i
=
0
;
i
<
len
;
++
i
)
{
sum
+=
query
_boundaries
[
i
];
sum
+=
query
[
i
];
}
if
(
num_data_
!=
sum
)
{
Log
::
Fatal
(
"sum of query counts is not same with #data"
);
}
if
(
!
query_boundaries_
.
empty
())
{
query_boundaries_
.
clear
();
}
num_queries_
=
len
;
query_boundaries_
=
std
::
vector
<
data_size_t
>
(
num_queries_
);
query_boundaries_
=
std
::
vector
<
data_size_t
>
(
num_queries_
+
1
);
query_boundaries_
[
0
]
=
0
;
for
(
data_size_t
i
=
0
;
i
<
num_queries_
;
++
i
)
{
query_boundaries_
[
i
]
=
query_boundaries
[
i
];
query_boundaries_
[
i
+
1
]
=
query_boundaries
_
[
i
]
+
query
[
i
];
}
LoadQueryWeights
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment