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
2a788165
Commit
2a788165
authored
Jul 27, 2017
by
Guolin Ke
Browse files
fix a bug for the label_index
parent
9ae1f9ac
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
1 deletion
+6
-1
src/io/dataset.cpp
src/io/dataset.cpp
+2
-1
src/io/dataset_loader.cpp
src/io/dataset_loader.cpp
+4
-0
No files found.
src/io/dataset.cpp
View file @
2a788165
...
...
@@ -526,7 +526,7 @@ void Dataset::SaveBinaryFile(const char* bin_filename) {
fwrite
(
binary_file_token
,
sizeof
(
char
),
size_of_token
,
file
);
// get size of header
size_t
size_of_header
=
sizeof
(
num_data_
)
+
sizeof
(
num_features_
)
+
sizeof
(
num_total_features_
)
+
sizeof
(
int
)
*
num_total_features_
+
sizeof
(
num_groups_
)
+
sizeof
(
int
)
*
num_total_features_
+
sizeof
(
label_idx_
)
+
sizeof
(
num_groups_
)
+
3
*
sizeof
(
int
)
*
num_features_
+
sizeof
(
uint64_t
)
*
(
num_groups_
+
1
)
+
2
*
sizeof
(
int
)
*
num_groups_
;
// size of feature names
for
(
int
i
=
0
;
i
<
num_total_features_
;
++
i
)
{
...
...
@@ -537,6 +537,7 @@ void Dataset::SaveBinaryFile(const char* bin_filename) {
fwrite
(
&
num_data_
,
sizeof
(
num_data_
),
1
,
file
);
fwrite
(
&
num_features_
,
sizeof
(
num_features_
),
1
,
file
);
fwrite
(
&
num_total_features_
,
sizeof
(
num_total_features_
),
1
,
file
);
fwrite
(
&
label_idx_
,
sizeof
(
label_idx_
),
1
,
file
);
fwrite
(
used_feature_map_
.
data
(),
sizeof
(
int
),
num_total_features_
,
file
);
fwrite
(
&
num_groups_
,
sizeof
(
num_groups_
),
1
,
file
);
fwrite
(
real_feature_idx_
.
data
(),
sizeof
(
int
),
num_features_
,
file
);
...
...
src/io/dataset_loader.cpp
View file @
2a788165
...
...
@@ -174,6 +174,7 @@ Dataset* DatasetLoader::LoadFromFile(const char* filename, int rank, int num_mac
Log
::
Fatal
(
"Could not recognize data format of %s"
,
filename
);
}
dataset
->
data_filename_
=
filename
;
dataset
->
label_idx_
=
label_idx_
;
dataset
->
metadata_
.
Init
(
filename
);
if
(
!
io_config_
.
use_two_round_loading
)
{
// read data to memory
...
...
@@ -228,6 +229,7 @@ Dataset* DatasetLoader::LoadFromFileAlignWithOtherDataset(const char* filename,
Log
::
Fatal
(
"Could not recognize data format of %s"
,
filename
);
}
dataset
->
data_filename_
=
filename
;
dataset
->
label_idx_
=
label_idx_
;
dataset
->
metadata_
.
Init
(
filename
);
if
(
!
io_config_
.
use_two_round_loading
)
{
// read data in memory
...
...
@@ -315,6 +317,8 @@ Dataset* DatasetLoader::LoadFromBinFile(const char* data_filename, const char* b
mem_ptr
+=
sizeof
(
dataset
->
num_features_
);
dataset
->
num_total_features_
=
*
(
reinterpret_cast
<
const
int
*>
(
mem_ptr
));
mem_ptr
+=
sizeof
(
dataset
->
num_total_features_
);
dataset
->
label_idx_
=
*
(
reinterpret_cast
<
const
int
*>
(
mem_ptr
));
mem_ptr
+=
sizeof
(
dataset
->
label_idx_
);
const
int
*
tmp_feature_map
=
reinterpret_cast
<
const
int
*>
(
mem_ptr
);
dataset
->
used_feature_map_
.
clear
();
for
(
int
i
=
0
;
i
<
dataset
->
num_total_features_
;
++
i
)
{
...
...
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