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
ee97ed3d
Commit
ee97ed3d
authored
Oct 21, 2016
by
Qiwei Ye
Browse files
using advanced logger for lightGBM
parent
2d0e8fc9
Changes
26
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
17 deletions
+21
-17
src/network/socket_wrapper.hpp
src/network/socket_wrapper.hpp
+10
-10
src/objective/binary_objective.hpp
src/objective/binary_objective.hpp
+3
-3
src/objective/rank_objective.hpp
src/objective/rank_objective.hpp
+2
-2
src/treelearner/serial_tree_learner.cpp
src/treelearner/serial_tree_learner.cpp
+2
-2
windows/LightGBM.vcxproj
windows/LightGBM.vcxproj
+1
-0
windows/LightGBM.vcxproj.filters
windows/LightGBM.vcxproj.filters
+3
-0
No files found.
src/network/socket_wrapper.hpp
View file @
ee97ed3d
...
...
@@ -60,7 +60,7 @@ public:
TcpSocket
()
{
sockfd_
=
socket
(
AF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
);
if
(
sockfd_
==
INVALID_SOCKET
)
{
Log
::
Stder
r
(
"socket construct error"
);
Log
::
Erro
r
(
"socket construct error"
);
return
;
}
ConfigSocket
();
...
...
@@ -69,7 +69,7 @@ public:
explicit
TcpSocket
(
SOCKET
socket
)
{
sockfd_
=
socket
;
if
(
sockfd_
==
INVALID_SOCKET
)
{
Log
::
Stder
r
(
"passed socket error"
);
Log
::
Erro
r
(
"passed socket error"
);
return
;
}
ConfigSocket
();
...
...
@@ -97,11 +97,11 @@ public:
#if defined(_WIN32)
WSADATA
wsa_data
;
if
(
WSAStartup
(
MAKEWORD
(
2
,
2
),
&
wsa_data
)
==
-
1
)
{
Log
::
Stder
r
(
"socket error: start up error"
);
Log
::
Erro
r
(
"socket error: start up error"
);
}
if
(
LOBYTE
(
wsa_data
.
wVersion
)
!=
2
||
HIBYTE
(
wsa_data
.
wVersion
)
!=
2
)
{
WSACleanup
();
Log
::
Stder
r
(
"socket error: Winsock.dll version error"
);
Log
::
Erro
r
(
"socket error: Winsock.dll version error"
);
}
#else
#endif
...
...
@@ -128,7 +128,7 @@ public:
char
buffer
[
512
];
// get hostName
if
(
gethostname
(
buffer
,
sizeof
(
buffer
))
==
SOCKET_ERROR
)
{
Log
::
Stder
r
(
"Error code: %d, when getting local host name."
,
WSAGetLastError
());
Log
::
Erro
r
(
"Error code: %d, when getting local host name."
,
WSAGetLastError
());
}
// push local ip
PIP_ADAPTER_INFO
pAdapterInfo
;
...
...
@@ -137,7 +137,7 @@ public:
ULONG
ulOutBufLen
=
sizeof
(
IP_ADAPTER_INFO
);
pAdapterInfo
=
(
IP_ADAPTER_INFO
*
)
MALLOC
(
sizeof
(
IP_ADAPTER_INFO
));
if
(
pAdapterInfo
==
NULL
)
{
Log
::
Stder
r
(
"Error allocating memory needed to call GetAdaptersinfo
\n
"
);
Log
::
Erro
r
(
"Error allocating memory needed to call GetAdaptersinfo
\n
"
);
}
// Make an initial call to GetAdaptersInfo to get
// the necessary size into the ulOutBufLen variable
...
...
@@ -145,7 +145,7 @@ public:
FREE
(
pAdapterInfo
);
pAdapterInfo
=
(
IP_ADAPTER_INFO
*
)
MALLOC
(
ulOutBufLen
);
if
(
pAdapterInfo
==
NULL
)
{
Log
::
Stder
r
(
"Error allocating memory needed to call GetAdaptersinfo
\n
"
);
Log
::
Erro
r
(
"Error allocating memory needed to call GetAdaptersinfo
\n
"
);
}
}
if
((
dwRetVal
=
GetAdaptersInfo
(
pAdapterInfo
,
&
ulOutBufLen
))
==
NO_ERROR
)
{
...
...
@@ -218,7 +218,7 @@ public:
inline
TcpSocket
Accept
()
{
SOCKET
newfd
=
accept
(
sockfd_
,
NULL
,
NULL
);
if
(
newfd
==
INVALID_SOCKET
)
{
Log
::
Stder
r
(
"socket accept error,error code: %d"
,
GetLastError
());
Log
::
Erro
r
(
"socket accept error,error code: %d"
,
GetLastError
());
}
return
TcpSocket
(
newfd
);
}
...
...
@@ -226,7 +226,7 @@ public:
inline
int
Send
(
const
char
*
buf_
,
int
len
,
int
flag
=
0
)
{
int
cur_cnt
=
send
(
sockfd_
,
buf_
,
len
,
flag
);
if
(
cur_cnt
==
SOCKET_ERROR
)
{
Log
::
Stder
r
(
"socket send error, error code: %d"
,
GetLastError
());
Log
::
Erro
r
(
"socket send error, error code: %d"
,
GetLastError
());
}
return
cur_cnt
;
}
...
...
@@ -234,7 +234,7 @@ public:
inline
int
Recv
(
char
*
buf_
,
int
len
,
int
flags
=
0
)
{
int
cur_cnt
=
recv
(
sockfd_
,
buf_
,
len
,
flags
);
if
(
cur_cnt
==
SOCKET_ERROR
)
{
Log
::
Stder
r
(
"socket recv error, error code: %d"
,
GetLastError
());
Log
::
Erro
r
(
"socket recv error, error code: %d"
,
GetLastError
());
}
return
cur_cnt
;
}
...
...
src/objective/binary_objective.hpp
View file @
ee97ed3d
...
...
@@ -16,7 +16,7 @@ public:
is_unbalance_
=
config
.
is_unbalance
;
sigmoid_
=
static_cast
<
score_t
>
(
config
.
sigmoid
);
if
(
sigmoid_
<=
0.0
)
{
Log
::
Stder
r
(
"sigmoid param %f should greater than zero"
,
sigmoid_
);
Log
::
Erro
r
(
"sigmoid param %f should greater than zero"
,
sigmoid_
);
}
}
~
BinaryLogloss
()
{}
...
...
@@ -34,10 +34,10 @@ public:
++
cnt_negative
;
}
}
Log
::
Stdout
(
"number of postive:%d number of negative:%d"
,
cnt_positive
,
cnt_negative
);
Log
::
Info
(
"number of postive:%d number of negative:%d"
,
cnt_positive
,
cnt_negative
);
// cannot continue if all sample are same class
if
(
cnt_positive
==
0
||
cnt_negative
==
0
)
{
Log
::
Stder
r
(
"input training data only contain one class"
);
Log
::
Erro
r
(
"input training data only contain one class"
);
}
// use -1 for negative class, and 1 for positive class
label_val_
[
0
]
=
-
1
;
...
...
src/objective/rank_objective.hpp
View file @
ee97ed3d
...
...
@@ -31,7 +31,7 @@ public:
optimize_pos_at_
=
config
.
max_position
;
sigmoid_table_
=
nullptr
;
if
(
sigmoid_
<=
0.0
)
{
Log
::
Stder
r
(
"sigmoid param %f should greater than zero"
,
sigmoid_
);
Log
::
Erro
r
(
"sigmoid param %f should greater than zero"
,
sigmoid_
);
}
}
~
LambdarankNDCG
()
{
...
...
@@ -47,7 +47,7 @@ public:
// get boundries
query_boundaries_
=
metadata
.
query_boundaries
();
if
(
query_boundaries_
==
nullptr
)
{
Log
::
Stder
r
(
"For NDCG metric, should have query information"
);
Log
::
Erro
r
(
"For NDCG metric, should have query information"
);
}
num_queries_
=
metadata
.
num_queries
();
// cache inverse max DCG, avoid compution many times
...
...
src/treelearner/serial_tree_learner.cpp
View file @
ee97ed3d
...
...
@@ -95,7 +95,7 @@ void SerialTreeLearner::Init(const Dataset* train_data) {
if
(
has_ordered_bin_
)
{
is_data_in_leaf_
=
new
char
[
num_data_
];
}
Log
::
Stdout
(
"#data:%d #feature:%d
\n
"
,
num_data_
,
num_features_
);
Log
::
Info
(
"#data:%d #feature:%d
\n
"
,
num_data_
,
num_features_
);
}
...
...
@@ -123,7 +123,7 @@ Tree* SerialTreeLearner::Train(const score_t* gradients, const score_t *hessians
const
SplitInfo
&
best_leaf_SplitInfo
=
best_split_per_leaf_
[
best_leaf
];
// cannot split, quit
if
(
best_leaf_SplitInfo
.
gain
<=
0.0
)
{
Log
::
Stdout
(
"cannot find more split with gain = %f , current #leaves=%d
\n
"
,
Log
::
Info
(
"cannot find more split with gain = %f , current #leaves=%d
\n
"
,
best_leaf_SplitInfo
.
gain
,
split
+
1
);
break
;
}
...
...
windows/LightGBM.vcxproj
View file @
ee97ed3d
...
...
@@ -197,6 +197,7 @@
<ClInclude
Include=
"..\src\treelearner\split_info.hpp"
/>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"..\include\LightGBM\utils\log.cpp"
/>
<ClCompile
Include=
"..\src\application\application.cpp"
/>
<ClCompile
Include=
"..\src\boosting\boosting.cpp"
/>
<ClCompile
Include=
"..\src\boosting\gbdt.cpp"
/>
...
...
windows/LightGBM.vcxproj.filters
View file @
ee97ed3d
...
...
@@ -221,5 +221,8 @@
<ClCompile
Include=
"..\src\main.cpp"
>
<Filter>
src
</Filter>
</ClCompile>
<ClCompile
Include=
"..\include\LightGBM\utils\log.cpp"
>
<Filter>
include\LightGBM\utils
</Filter>
</ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
Prev
1
2
Next
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