wandb 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/wandb/version.rb +1 -1
- data/lib/wandb/xgboost_callback.rb +25 -19
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f0f0909ffdfe53479bf0c6a09f09f96c7e0aec1dc846f16d9b42c1b1e7f4fae
|
4
|
+
data.tar.gz: f1ffc1d2cdabc05964ef0187f5ab168a71ef38077591e3a07bf960da3b5ae8b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93b0f7df5f4bb660a9d566b3492a75690336eeddbfbe0aad15fc100c292499f5fb93a543f1f9f72b6120b2682d8ee25dd3b5ead6906500efd1f5ccc29f6a7219
|
7
|
+
data.tar.gz: 95e7472bfa9e0322bb353d6ee77bd76a7b6f1c09edd6ef23f10f294ef982b35bae279b5ccbb4beee44991decf774b3bac45ab708ebbab4dbb0dda47917715545
|
data/lib/wandb/version.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "xgb"
|
2
2
|
require "tempfile"
|
3
3
|
require "fileutils"
|
4
|
+
require "xgboost/training_callback"
|
4
5
|
|
5
6
|
module Wandb
|
6
7
|
class XGBoostCallback < XGBoost::TrainingCallback
|
@@ -19,7 +20,7 @@ module Wandb
|
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
22
|
-
attr_accessor :project_name, :api_key
|
23
|
+
attr_accessor :project_name, :api_key, :custom_loggers
|
23
24
|
|
24
25
|
def initialize(options = {})
|
25
26
|
options = Opts.new(options)
|
@@ -29,22 +30,21 @@ module Wandb
|
|
29
30
|
@define_metric = options.default(:define_metric, true)
|
30
31
|
@api_key = options.default(:api_key, ENV["WANDB_API_KEY"])
|
31
32
|
@project_name = options.default(:project_name, nil)
|
32
|
-
|
33
|
-
raise "WANDB_API_KEY required" unless api_key
|
34
|
-
raise "project_name required" unless project_name
|
35
|
-
|
36
|
-
Wandb.login(api_key: api_key)
|
37
|
-
Wandb.init(project: project_name)
|
38
|
-
|
39
|
-
return if Wandb.current_run
|
40
|
-
|
41
|
-
raise "You must call wandb.init() before WandbCallback()"
|
33
|
+
@custom_loggers = options.default(:custom_loggers, [])
|
42
34
|
end
|
43
35
|
|
44
36
|
def before_training(model)
|
45
|
-
|
46
|
-
Wandb.
|
47
|
-
|
37
|
+
Wandb.login(api_key: api_key)
|
38
|
+
Wandb.init(project: project_name)
|
39
|
+
config = JSON.parse(model.save_config)
|
40
|
+
log_conf = {
|
41
|
+
learning_rate: config.dig("learner", "gradient_booster", "tree_train_param", "learning_rate").to_f,
|
42
|
+
max_depth: config.dig("learner", "gradient_booster", "tree_train_param", "max_depth").to_f,
|
43
|
+
n_estimators: model.num_boosted_rounds
|
44
|
+
}
|
45
|
+
Wandb.current_run.config = log_conf
|
46
|
+
|
47
|
+
Wandb.log(log_conf)
|
48
48
|
model
|
49
49
|
end
|
50
50
|
|
@@ -57,7 +57,7 @@ module Wandb
|
|
57
57
|
|
58
58
|
# Log best score and best iteration
|
59
59
|
unless model.best_score
|
60
|
-
|
60
|
+
finish
|
61
61
|
return model
|
62
62
|
end
|
63
63
|
|
@@ -65,18 +65,21 @@ module Wandb
|
|
65
65
|
"best_score" => model.best_score.to_f,
|
66
66
|
"best_iteration" => model.best_iteration.to_i
|
67
67
|
)
|
68
|
-
|
69
|
-
Wandb.finish
|
70
|
-
FileUtils.rm_rf(Rails.root.join("wandb"))
|
68
|
+
finish
|
71
69
|
|
72
70
|
model
|
73
71
|
end
|
74
72
|
|
73
|
+
def finish
|
74
|
+
Wandb.finish
|
75
|
+
FileUtils.rm_rf(File.join(Dir.pwd, "wandb"))
|
76
|
+
end
|
77
|
+
|
75
78
|
def before_iteration(_model, _epoch, _history)
|
76
79
|
false
|
77
80
|
end
|
78
81
|
|
79
|
-
def after_iteration(
|
82
|
+
def after_iteration(model, epoch, history)
|
80
83
|
history.each do |split, metric_scores|
|
81
84
|
metric = metric_scores.keys.first
|
82
85
|
values = metric_scores.values.last
|
@@ -86,6 +89,9 @@ module Wandb
|
|
86
89
|
full_metric_name = "#{split}-#{metric}"
|
87
90
|
Wandb.log({ full_metric_name => epoch_value })
|
88
91
|
end
|
92
|
+
@custom_loggers.each do |logger|
|
93
|
+
logger.call(model, epoch, history)
|
94
|
+
end
|
89
95
|
Wandb.log("epoch" => epoch)
|
90
96
|
false
|
91
97
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wandb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Shollenberger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pycall
|