id int64 1 6.07M | name stringlengths 1 295 | code stringlengths 12 426k | language stringclasses 1
value | source_file stringlengths 5 202 | start_line int64 1 158k | end_line int64 1 158k | repo dict |
|---|---|---|---|---|---|---|---|
2,301 | on_epoch_end | def on_epoch_end(self, epoch, logs={}):
if self.log_weights:
wandb.log(self._log_weights(), commit=False)
if self.log_gradients:
wandb.log(self._log_gradients(), commit=False)
if self.input_type in (
"image",
"images",
"segmentation_m... | python | wandb/integration/keras/keras.py | 581 | 632 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,302 | on_batch_begin | def on_batch_begin(self, batch, logs=None):
pass | python | wandb/integration/keras/keras.py | 635 | 636 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,303 | on_batch_end | def on_batch_end(self, batch, logs=None):
if self.save_graph and not self._graph_rendered:
# Couldn't do this in train_begin because keras may still not be built
wandb.run.summary["graph"] = wandb.Graph.from_keras(self.model)
self._graph_rendered = True
if self.log_b... | python | wandb/integration/keras/keras.py | 639 | 646 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,304 | on_train_batch_begin | def on_train_batch_begin(self, batch, logs=None):
self._model_trained_since_last_eval = True | python | wandb/integration/keras/keras.py | 648 | 649 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,305 | on_train_batch_end | def on_train_batch_end(self, batch, logs=None):
if self.save_graph and not self._graph_rendered:
# Couldn't do this in train_begin because keras may still not be built
wandb.run.summary["graph"] = wandb.Graph.from_keras(self.model)
self._graph_rendered = True
if self... | python | wandb/integration/keras/keras.py | 651 | 658 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,306 | on_test_begin | def on_test_begin(self, logs=None):
pass | python | wandb/integration/keras/keras.py | 660 | 661 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,307 | on_test_end | def on_test_end(self, logs=None):
pass | python | wandb/integration/keras/keras.py | 663 | 664 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,308 | on_test_batch_begin | def on_test_batch_begin(self, batch, logs=None):
pass | python | wandb/integration/keras/keras.py | 666 | 667 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,309 | on_test_batch_end | def on_test_batch_end(self, batch, logs=None):
pass | python | wandb/integration/keras/keras.py | 669 | 670 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,310 | on_train_begin | def on_train_begin(self, logs=None):
if self.log_evaluation:
try:
validation_data = None
if self.validation_data:
validation_data = self.validation_data
elif self.generator:
if not self.validation_steps:
... | python | wandb/integration/keras/keras.py | 672 | 723 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,311 | on_train_end | def on_train_end(self, logs=None):
if self._model_trained_since_last_eval:
self._attempt_evaluation_log() | python | wandb/integration/keras/keras.py | 725 | 727 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,312 | on_test_begin | def on_test_begin(self, logs=None):
pass | python | wandb/integration/keras/keras.py | 729 | 730 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,313 | on_test_end | def on_test_end(self, logs=None):
pass | python | wandb/integration/keras/keras.py | 732 | 733 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,314 | on_test_batch_begin | def on_test_batch_begin(self, batch, logs=None):
pass | python | wandb/integration/keras/keras.py | 735 | 736 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,315 | on_test_batch_end | def on_test_batch_end(self, batch, logs=None):
pass | python | wandb/integration/keras/keras.py | 738 | 739 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,316 | on_predict_begin | def on_predict_begin(self, logs=None):
pass | python | wandb/integration/keras/keras.py | 741 | 742 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,317 | on_predict_end | def on_predict_end(self, logs=None):
pass | python | wandb/integration/keras/keras.py | 744 | 745 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,318 | on_predict_batch_begin | def on_predict_batch_begin(self, batch, logs=None):
pass | python | wandb/integration/keras/keras.py | 747 | 748 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,319 | on_predict_batch_end | def on_predict_batch_end(self, batch, logs=None):
pass | python | wandb/integration/keras/keras.py | 750 | 751 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,320 | _logits_to_captions | def _logits_to_captions(self, logits):
if logits[0].shape[-1] == 1:
# Scalar output from the model
# TODO: handle validation_y
if len(self.labels) == 2:
# User has named true and false
captions = [
self.labels[1] if logits[0... | python | wandb/integration/keras/keras.py | 753 | 785 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,321 | _masks_to_pixels | def _masks_to_pixels(self, masks):
# if its a binary mask, just return it as grayscale instead of picking the argmax
if len(masks[0].shape) == 2 or masks[0].shape[-1] == 1:
return masks
class_colors = (
self.class_colors
if self.class_colors is not None
... | python | wandb/integration/keras/keras.py | 787 | 797 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,322 | _log_images | def _log_images(self, num_images=36):
validation_X = self.validation_data[0]
validation_y = self.validation_data[1]
validation_length = len(validation_X)
if validation_length > num_images:
# pick some data at random
indices = np.random.choice(validation_length, ... | python | wandb/integration/keras/keras.py | 799 | 914 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,323 | _log_weights | def _log_weights(self):
metrics = {}
for layer in self.model.layers:
weights = layer.get_weights()
if len(weights) == 1:
_update_if_numeric(
metrics, "parameters/" + layer.name + ".weights", weights[0]
)
elif len(wei... | python | wandb/integration/keras/keras.py | 916 | 931 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,324 | _log_gradients | def _log_gradients(self):
# Suppress callback warnings grad accumulator
og_level = tf_logger.level
tf_logger.setLevel("ERROR")
self._grad_accumulator_model.fit(
self._training_data_x,
self._training_data_y,
verbose=0,
callbacks=[self._grad... | python | wandb/integration/keras/keras.py | 933 | 952 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,325 | _log_dataframe | def _log_dataframe(self):
x, y_true, y_pred = None, None, None
if self.validation_data:
x, y_true = self.validation_data[0], self.validation_data[1]
y_pred = self.model.predict(x)
elif self.generator:
if not self.validation_steps:
wandb.termwa... | python | wandb/integration/keras/keras.py | 954 | 1,000 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,326 | _save_model | def _save_model(self, epoch):
if wandb.run.disabled:
return
if self.verbose > 0:
print(
"Epoch %05d: %s improved from %0.5f to %0.5f,"
" saving model to %s"
% (epoch, self.monitor, self.best, self.current, self.filepath)
... | python | wandb/integration/keras/keras.py | 1,002 | 1,023 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,327 | _save_model_as_artifact | def _save_model_as_artifact(self, epoch):
if wandb.run.disabled:
return
# Save the model in the SavedModel format.
# TODO: Replace this manual artifact creation with the `log_model` method
# after `log_model` is released from beta.
self.model.save(self.filepath[:-3],... | python | wandb/integration/keras/keras.py | 1,025 | 1,041 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,328 | get_flops | def get_flops(self) -> float:
"""
Calculate FLOPS [GFLOPs] for a tf.keras.Model or tf.keras.Sequential model
in inference mode. It uses tf.compat.v1.profiler under the hood.
"""
if not hasattr(self, "model"):
raise wandb.Error("self.model must be set before using this... | python | wandb/integration/keras/keras.py | 1,043 | 1,089 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,329 | __init__ | def __init__(
self,
data_table_columns: List[str],
pred_table_columns: List[str],
*args: Any,
**kwargs: Any,
) -> None:
super().__init__(*args, **kwargs)
if wandb.run is None:
raise wandb.Error(
"You must call `wandb.init()` first ... | python | wandb/integration/keras/callbacks/tables_builder.py | 91 | 109 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,330 | on_train_begin | def on_train_begin(self, logs: Optional[Dict[str, float]] = None) -> None:
# Initialize the data_table
self.init_data_table(column_names=self.data_table_columns)
# Log the ground truth data
self.add_ground_truth(logs)
# Log the data_table as W&B Artifacts
self.log_data_ta... | python | wandb/integration/keras/callbacks/tables_builder.py | 111 | 117 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,331 | on_epoch_end | def on_epoch_end(self, epoch: int, logs: Optional[Dict[str, float]] = None) -> None:
# Initialize the pred_table
self.init_pred_table(column_names=self.pred_table_columns)
# Log the model prediction
self.add_model_predictions(epoch, logs)
# Log the pred_table as W&B Artifacts
... | python | wandb/integration/keras/callbacks/tables_builder.py | 119 | 125 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,332 | add_ground_truth | def add_ground_truth(self, logs: Optional[Dict[str, float]] = None) -> None:
"""Add ground truth data to `data_table`.
Use this method to write the logic for adding validation/training data to
`data_table` initialized using `init_data_table` method.
Example:
```
... | python | wandb/integration/keras/callbacks/tables_builder.py | 128 | 144 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,333 | add_model_predictions | def add_model_predictions(
self, epoch: int, logs: Optional[Dict[str, float]] = None
) -> None:
"""Add a prediction from a model to `pred_table`.
Use this method to write the logic for adding model prediction for validation/
training data to `pred_table` initialized using `init_pred... | python | wandb/integration/keras/callbacks/tables_builder.py | 147 | 168 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,334 | init_data_table | def init_data_table(self, column_names: List[str]) -> None:
"""Initialize the W&B Tables for validation data.
Call this method `on_train_begin` or equivalent hook. This is followed by adding
data to the table row or column wise.
Args:
column_names (list): Column names for W... | python | wandb/integration/keras/callbacks/tables_builder.py | 170 | 179 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,335 | init_pred_table | def init_pred_table(self, column_names: List[str]) -> None:
"""Initialize the W&B Tables for model evaluation.
Call this method `on_epoch_end` or equivalent hook. This is followed by adding
data to the table row or column wise.
Args:
column_names (list): Column names for W&... | python | wandb/integration/keras/callbacks/tables_builder.py | 181 | 190 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,336 | log_data_table | def log_data_table(
self, name: str = "val", type: str = "dataset", table_name: str = "val_data"
) -> None:
"""Log the `data_table` as W&B artifact and call `use_artifact` on it.
This lets the evaluation table use the reference of already uploaded data
(images, text, scalar, etc.) w... | python | wandb/integration/keras/callbacks/tables_builder.py | 192 | 218 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,337 | log_pred_table | def log_pred_table(
self,
type: str = "evaluation",
table_name: str = "eval_data",
aliases: Optional[List[str]] = None,
) -> None:
"""Log the W&B Tables for model evaluation.
The table will be logged multiple times creating new version. Use this
to compare mo... | python | wandb/integration/keras/callbacks/tables_builder.py | 220 | 241 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,338 | __init__ | def __init__(
self,
filepath: Union[str, os.PathLike],
monitor: str = "val_loss",
verbose: int = 0,
save_best_only: bool = False,
save_weights_only: bool = False,
mode: Mode = "auto",
save_freq: Union[SaveStrategy, int] = "epoch",
options: Optional... | python | wandb/integration/keras/callbacks/model_checkpoint.py | 73 | 111 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,339 | on_train_batch_end | def on_train_batch_end(
self, batch: int, logs: Optional[Dict[str, float]] = None
) -> None:
if self._should_save_on_batch(batch):
if self.is_old_tf_keras_version:
# Save the model and get filepath
self._save_model(epoch=self._current_epoch, logs=logs)
... | python | wandb/integration/keras/callbacks/model_checkpoint.py | 113 | 129 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,340 | on_epoch_end | def on_epoch_end(self, epoch: int, logs: Optional[Dict[str, float]] = None) -> None:
super().on_epoch_end(epoch, logs)
# Check if model checkpoint is created at the end of epoch.
if self.save_freq == "epoch":
# Get filepath where the model checkpoint is saved.
if self.is_... | python | wandb/integration/keras/callbacks/model_checkpoint.py | 131 | 142 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,341 | _log_ckpt_as_artifact | def _log_ckpt_as_artifact(
self, filepath: str, aliases: Optional[List[str]] = None
) -> None:
"""Log model checkpoint as W&B Artifact."""
try:
assert wandb.run is not None
model_artifact = wandb.Artifact(f"run_{wandb.run.id}_model", type="model")
if self... | python | wandb/integration/keras/callbacks/model_checkpoint.py | 144 | 171 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,342 | _check_filepath | def _check_filepath(self) -> None:
placeholders = []
for tup in string.Formatter().parse(self.filepath):
if tup[1] is not None:
placeholders.append(tup[1])
if len(placeholders) == 0:
wandb.termwarn(
"When using `save_best_only`, ensure that... | python | wandb/integration/keras/callbacks/model_checkpoint.py | 173 | 184 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,343 | is_old_tf_keras_version | def is_old_tf_keras_version(self) -> Optional[bool]:
if self._is_old_tf_keras_version is None:
from pkg_resources import parse_version
if parse_version(tf.keras.__version__) < parse_version("2.6.0"):
self._is_old_tf_keras_version = True
else:
... | python | wandb/integration/keras/callbacks/model_checkpoint.py | 187 | 196 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,344 | __init__ | def __init__(
self,
log_freq: Union[LogStrategy, int] = "epoch",
initial_global_step: int = 0,
*args: Any,
**kwargs: Any,
) -> None:
super().__init__(*args, **kwargs)
if wandb.run is None:
raise wandb.Error(
"You must call `wandb.i... | python | wandb/integration/keras/callbacks/metrics_logger.py | 52 | 86 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,345 | _get_lr | def _get_lr(self) -> Union[float, None]:
if isinstance(self.model.optimizer.learning_rate, tf.Variable):
return float(self.model.optimizer.learning_rate.numpy().item())
try:
return float(
self.model.optimizer.learning_rate(step=self.global_step).numpy().item()
... | python | wandb/integration/keras/callbacks/metrics_logger.py | 88 | 97 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,346 | on_epoch_end | def on_epoch_end(self, epoch: int, logs: Optional[Dict[str, Any]] = None) -> None:
"""Called at the end of an epoch."""
logs = dict() if logs is None else {f"epoch/{k}": v for k, v in logs.items()}
logs["epoch/epoch"] = epoch
lr = self._get_lr()
if lr is not None:
l... | python | wandb/integration/keras/callbacks/metrics_logger.py | 99 | 109 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,347 | on_batch_end | def on_batch_end(self, batch: int, logs: Optional[Dict[str, Any]] = None) -> None:
self.global_step += 1
"""An alias for `on_train_batch_end` for backwards compatibility."""
if self.logging_batch_wise and batch % self.log_freq == 0:
logs = {f"batch/{k}": v for k, v in logs.items()} i... | python | wandb/integration/keras/callbacks/metrics_logger.py | 111 | 124 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,348 | on_train_batch_end | def on_train_batch_end(
self, batch: int, logs: Optional[Dict[str, Any]] = None
) -> None:
"""Called at the end of a training batch in `fit` methods."""
self.on_batch_end(batch, logs if logs else {}) | python | wandb/integration/keras/callbacks/metrics_logger.py | 126 | 130 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,349 | __init__ | def __init__(
self,
verbose: int = 0,
model_save_path: Optional[str] = None,
model_save_freq: int = 0,
gradient_save_freq: int = 0,
log: Optional[Literal["gradients", "parameters", "all"]] = "all",
) -> None:
super().__init__(verbose)
if wandb.run is N... | python | wandb/integration/sb3/sb3.py | 87 | 117 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,350 | _init_callback | def _init_callback(self) -> None:
d = {}
if "algo" not in d:
d["algo"] = type(self.model).__name__
for key in self.model.__dict__:
if key in wandb.config:
continue
if type(self.model.__dict__[key]) in [float, int, str]:
d[key] =... | python | wandb/integration/sb3/sb3.py | 119 | 136 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,351 | _on_step | def _on_step(self) -> bool:
if self.model_save_freq > 0:
if self.model_save_path is not None:
if self.n_calls % self.model_save_freq == 0:
self.save_model()
return True | python | wandb/integration/sb3/sb3.py | 138 | 143 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,352 | _on_training_end | def _on_training_end(self) -> None:
if self.model_save_path is not None:
self.save_model() | python | wandb/integration/sb3/sb3.py | 145 | 147 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,353 | save_model | def save_model(self) -> None:
self.model.save(self.path)
wandb.save(self.path, base_path=self.model_save_path)
if self.verbose > 1:
logger.info(f"Saving model checkpoint to {self.path}") | python | wandb/integration/sb3/sb3.py | 149 | 153 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,354 | wandb_callback | def wandb_callback() -> "Callable":
"""Old style callback that will be deprecated in favor of WandbCallback. Please try the new logger for more features."""
warnings.warn(
"wandb_callback will be deprecated in favor of WandbCallback. Please use WandbCallback for more features.",
UserWarning,
... | python | wandb/integration/xgboost/xgboost.py | 36 | 52 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,355 | callback | def callback(env: "CallbackEnv") -> None:
for k, v in env.evaluation_result_list:
wandb.log({k: v}, commit=False)
wandb.log({}) | python | wandb/integration/xgboost/xgboost.py | 47 | 50 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,356 | __init__ | def __init__(
self,
log_model: bool = False,
log_feature_importance: bool = True,
importance_type: str = "gain",
define_metric: bool = True,
):
self.log_model: bool = log_model
self.log_feature_importance: bool = log_feature_importance
self.importance... | python | wandb/integration/xgboost/xgboost.py | 95 | 112 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,357 | before_training | def before_training(self, model: Booster) -> Booster:
"""Run before training is finished."""
# Update W&B config
config = model.save_config()
wandb.config.update(json.loads(config))
return model | python | wandb/integration/xgboost/xgboost.py | 114 | 120 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,358 | after_training | def after_training(self, model: Booster) -> Booster:
"""Run after training is finished."""
# Log the booster model as artifacts
if self.log_model:
self._log_model_as_artifact(model)
# Plot feature importance
if self.log_feature_importance:
self._log_featu... | python | wandb/integration/xgboost/xgboost.py | 122 | 141 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,359 | after_iteration | def after_iteration(self, model: Booster, epoch: int, evals_log: dict) -> bool:
"""Run after each iteration. Return True when training should stop."""
# Log metrics
for data, metric in evals_log.items():
for metric_name, log in metric.items():
if self.define_metric:
... | python | wandb/integration/xgboost/xgboost.py | 143 | 158 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,360 | _log_model_as_artifact | def _log_model_as_artifact(self, model: Booster) -> None:
model_name = f"{wandb.run.id}_model.json" # type: ignore
model_path = Path(wandb.run.dir) / model_name # type: ignore
model.save_model(str(model_path))
model_artifact = wandb.Artifact(name=model_name, type="model")
mode... | python | wandb/integration/xgboost/xgboost.py | 160 | 167 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,361 | _log_feature_importance | def _log_feature_importance(self, model: Booster) -> None:
fi = model.get_score(importance_type=self.importance_type)
fi_data = [[k, fi[k]] for k in fi]
table = wandb.Table(data=fi_data, columns=["Feature", "Importance"])
wandb.log(
{
"Feature Importance": wan... | python | wandb/integration/xgboost/xgboost.py | 169 | 179 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,362 | _define_metric | def _define_metric(self, data: str, metric_name: str) -> None:
if "loss" in str.lower(metric_name):
wandb.define_metric(f"{data}-{metric_name}", summary="min")
elif str.lower(metric_name) in MINIMIZE_METRICS:
wandb.define_metric(f"{data}-{metric_name}", summary="min")
eli... | python | wandb/integration/xgboost/xgboost.py | 181 | 189 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,363 | __init__ | def __init__(self, **kwargs):
self.run = wandb.init(**kwargs)
self.resources = {} | python | wandb/integration/sacred/__init__.py | 58 | 60 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,364 | started_event | def started_event(
self, ex_info, command, host_info, start_time, config, meta_info, _id
):
# TODO: add the source code file
# TODO: add dependencies and metadata.
self.__update_config(config) | python | wandb/integration/sacred/__init__.py | 62 | 67 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,365 | completed_event | def completed_event(self, stop_time, result):
if result:
if not isinstance(result, tuple):
result = (
result,
) # transform single result to tuple so that both single & multiple results use same code
for i, r in enumerate(result):
... | python | wandb/integration/sacred/__init__.py | 69 | 93 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,366 | artifact_event | def artifact_event(self, name, filename, metadata=None, content_type=None):
if content_type is None:
content_type = "file"
artifact = wandb.Artifact(name, type=content_type)
artifact.add_file(filename)
self.run.log_artifact(artifact) | python | wandb/integration/sacred/__init__.py | 95 | 100 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,367 | resource_event | def resource_event(self, filename):
"""TODO: Maintain resources list."""
if filename not in self.resources:
md5 = get_digest(filename)
self.resources[filename] = md5 | python | wandb/integration/sacred/__init__.py | 102 | 106 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,368 | log_metrics | def log_metrics(self, metrics_by_name, info):
for metric_name, metric_ptr in metrics_by_name.items():
for _step, value in zip(metric_ptr["steps"], metric_ptr["values"]):
if isinstance(value, numpy.ndarray):
wandb.log({metric_name: wandb.Image(value)})
... | python | wandb/integration/sacred/__init__.py | 108 | 114 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,369 | __update_config | def __update_config(self, config):
for k, v in config.items():
self.run.config[k] = v
self.run.config["resources"] = [] | python | wandb/integration/sacred/__init__.py | 116 | 119 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,370 | wandb_log | def wandb_log( # noqa: C901
func=None,
# /, # py38 only
log_component_file=True,
):
"""Wrap a standard python function and log to W&B."""
import json
import os
from functools import wraps
from inspect import Parameter, signature
from kfp import components
from kfp.components i... | python | wandb/integration/kfp/wandb_logging.py | 1 | 182 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,371 | isinstance_namedtuple | def isinstance_namedtuple(x):
t = type(x)
b = t.__bases__
if len(b) != 1 or b[0] != tuple:
return False
f = getattr(t, "_fields", None)
if not isinstance(f, tuple):
return False
return all(type(n) == str for n in f) | python | wandb/integration/kfp/wandb_logging.py | 30 | 38 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,372 | get_iframe_html | def get_iframe_html(run):
return f'<iframe src="{run.url}?kfp=true" style="border:none;width:100%;height:100%;min-width:900px;min-height:600px;"></iframe>' | python | wandb/integration/kfp/wandb_logging.py | 40 | 41 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,373 | get_link_back_to_kubeflow | def get_link_back_to_kubeflow():
wandb_kubeflow_url = os.getenv("WANDB_KUBEFLOW_URL")
return f"{wandb_kubeflow_url}/#/runs/details/{{workflow.uid}}" | python | wandb/integration/kfp/wandb_logging.py | 43 | 45 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,374 | log_input_scalar | def log_input_scalar(name, data, run=None):
run.config[name] = data
wandb.termlog(f"Setting config: {name} to {data}") | python | wandb/integration/kfp/wandb_logging.py | 47 | 49 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,375 | log_input_artifact | def log_input_artifact(name, data, type, run=None):
artifact = wandb.Artifact(name, type=type)
artifact.add_file(data)
run.use_artifact(artifact)
wandb.termlog(f"Using artifact: {name}") | python | wandb/integration/kfp/wandb_logging.py | 51 | 55 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,376 | log_output_scalar | def log_output_scalar(name, data, run=None):
if isinstance_namedtuple(data):
for k, v in zip(data._fields, data):
run.log({f"{func.__name__}.{k}": v})
else:
run.log({name: data}) | python | wandb/integration/kfp/wandb_logging.py | 57 | 62 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,377 | log_output_artifact | def log_output_artifact(name, data, type, run=None):
artifact = wandb.Artifact(name, type=type)
artifact.add_file(data)
run.log_artifact(artifact)
wandb.termlog(f"Logging artifact: {name}") | python | wandb/integration/kfp/wandb_logging.py | 64 | 68 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,378 | _log_component_file | def _log_component_file(func, run=None):
name = func.__name__
output_component_file = f"{name}.yml"
components._python_op.func_to_component_file(func, output_component_file)
artifact = wandb.Artifact(name, type="kubeflow_component_file")
artifact.add_file(output_component_file)
... | python | wandb/integration/kfp/wandb_logging.py | 70 | 77 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,379 | decorator | def decorator(func):
input_scalars = {}
input_artifacts = {}
output_scalars = {}
output_artifacts = {}
for name, ann in func.__annotations__.items():
if name == "return":
output_scalars[name] = ann
elif isinstance(ann, output_types):
... | python | wandb/integration/kfp/wandb_logging.py | 106 | 177 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,380 | wrapper | def wrapper(*args, **kwargs):
bound = new_sig.bind(*args, **kwargs)
bound.apply_defaults()
mlpipeline_ui_metadata_path = bound.arguments["mlpipeline_ui_metadata_path"]
del bound.arguments["mlpipeline_ui_metadata_path"]
with wandb.init(
job_ty... | python | wandb/integration/kfp/wandb_logging.py | 123 | 173 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,381 | full_path_exists | def full_path_exists(full_func):
def get_parent_child_pairs(full_func):
components = full_func.split(".")
parents, children = [], []
for i, _ in enumerate(components[:-1], 1):
parent = ".".join(components[:i])
child = components[i]
parents.append(parent)
... | python | wandb/integration/kfp/kfp_patch.py | 46 | 61 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,382 | get_parent_child_pairs | def get_parent_child_pairs(full_func):
components = full_func.split(".")
parents, children = [], []
for i, _ in enumerate(components[:-1], 1):
parent = ".".join(components[:i])
child = components[i]
parents.append(parent)
children.append(child)
... | python | wandb/integration/kfp/kfp_patch.py | 47 | 55 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,383 | patch | def patch(module_name, func):
module = wandb.util.get_module(module_name)
success = False
full_func = f"{module_name}.{func.__name__}"
if not full_path_exists(full_func):
wandb.termerror(
f"Failed to patch {module_name}.{func.__name__}! Please check if this package/module is instal... | python | wandb/integration/kfp/kfp_patch.py | 64 | 82 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,384 | unpatch | def unpatch(module_name):
if module_name in wandb.patched:
for module, func in wandb.patched[module_name]:
setattr(module, func, getattr(module, f"orig_{func}"))
wandb.patched[module_name] = [] | python | wandb/integration/kfp/kfp_patch.py | 85 | 89 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,385 | unpatch_kfp | def unpatch_kfp():
unpatch("kfp.components")
unpatch("kfp.components._python_op")
unpatch("wandb.integration.kfp") | python | wandb/integration/kfp/kfp_patch.py | 92 | 95 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,386 | patch_kfp | def patch_kfp():
to_patch = [
(
"kfp.components",
create_component_from_func,
),
(
"kfp.components._python_op",
create_component_from_func,
),
(
"kfp.components._python_op",
_get_function_source_definitio... | python | wandb/integration/kfp/kfp_patch.py | 98 | 123 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,387 | wandb_log | def wandb_log(
func=None,
# /, # py38 only
log_component_file=True,
):
"""Wrap a standard python function and log to W&B.
NOTE: Because patching failed, this decorator is a no-op.
"""
from functools import wraps
def decorator(func):
@wraps(func)
def wrapper(*args, **kw... | python | wandb/integration/kfp/kfp_patch.py | 126 | 147 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,388 | decorator | def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
return func(*args, **kwargs)
return wrapper | python | wandb/integration/kfp/kfp_patch.py | 137 | 142 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,389 | wrapper | def wrapper(*args, **kwargs):
return func(*args, **kwargs) | python | wandb/integration/kfp/kfp_patch.py | 139 | 140 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,390 | _get_function_source_definition | def _get_function_source_definition(func: Callable) -> str:
"""Get the source code of a function.
This function is modified from KFP. The original source is below:
https://github.com/kubeflow/pipelines/blob/b6406b02f45cdb195c7b99e2f6d22bf85b12268b/sdk/python/kfp/components/_python_op.py#L300-L319.
"""... | python | wandb/integration/kfp/kfp_patch.py | 150 | 176 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,391 | create_component_from_func | def create_component_from_func(
func: Callable,
output_component_file: Optional[str] = None,
base_image: Optional[str] = None,
packages_to_install: Optional[List[str]] = None,
annotations: Optional[Mapping[str, str]] = None,
):
'''Convert a Python function to a component and returns a task facto... | python | wandb/integration/kfp/kfp_patch.py | 179 | 303 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,392 | strip_type_hints | def strip_type_hints(source_code: str) -> str:
"""Strip type hints from source code.
This function is modified from KFP. The original source is below:
https://github.com/kubeflow/pipelines/blob/b6406b02f45cdb195c7b99e2f6d22bf85b12268b/sdk/python/kfp/components/_python_op.py#L237-L248.
"""
# For wa... | python | wandb/integration/kfp/kfp_patch.py | 306 | 324 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,393 | add_wandb_visualization | def add_wandb_visualization(run, mlpipeline_ui_metadata_path):
"""NOTE: To use this, you must modify your component to have an output called `mlpipeline_ui_metadata_path` AND call `wandb.init` yourself inside that component.
Example usage:
def my_component(..., mlpipeline_ui_metadata_path: OutputPath()):
... | python | wandb/integration/kfp/helpers.py | 4 | 28 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,394 | get_iframe_html | def get_iframe_html(run):
return f'<iframe src="{run.url}?kfp=true" style="border:none;width:100%;height:100%;min-width:900px;min-height:600px;"></iframe>' | python | wandb/integration/kfp/helpers.py | 19 | 20 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,395 | __init__ | def __init__(
self,
learn: "fastai.basic_train.Learner",
log: Optional[Literal["gradients", "parameters", "all"]] = "gradients",
save_model: bool = True,
monitor: Optional[str] = None,
mode: Literal["auto", "min", "max"] = "auto",
input_type: Optional[Literal["ima... | python | wandb/integration/fastai/__init__.py | 83 | 118 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,396 | on_train_begin | def on_train_begin(self, **kwargs: Any) -> None:
"""Call watch method to log model topology, gradients & weights."""
# Set self.best, method inherited from "TrackerCallback" by "SaveModelCallback"
super().on_train_begin()
# Ensure we don't call "watch" multiple times
if not Wand... | python | wandb/integration/fastai/__init__.py | 120 | 130 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,397 | on_epoch_end | def on_epoch_end(
self, epoch: int, smooth_loss: float, last_metrics: list, **kwargs: Any
) -> None:
"""Log training loss, validation loss and custom metrics & log prediction samples & save model."""
if self.save_model:
# Adapted from fast.ai "SaveModelCallback"
curre... | python | wandb/integration/fastai/__init__.py | 132 | 170 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,398 | on_train_end | def on_train_end(self, **kwargs: Any) -> None:
"""Load the best model."""
if self.save_model:
# Adapted from fast.ai "SaveModelCallback"
if self.model_path.is_file():
with self.model_path.open("rb") as model_file:
self.learn.load(model_file, pu... | python | wandb/integration/fastai/__init__.py | 172 | 179 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,399 | _wandb_log_predictions | def _wandb_log_predictions(self) -> None:
"""Log prediction samples."""
pred_log = []
if self.validation_data is None:
return
for x, y in self.validation_data:
try:
pred = self.learn.predict(x)
except Exception:
raise ... | python | wandb/integration/fastai/__init__.py | 181 | 244 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,400 | __init__ | def __init__(self, summary_op=None, steps_per_log=1000, history=None):
self._summary_op = summary_op
self._steps_per_log = steps_per_log
self._history = history
with telemetry.context() as tel:
tel.feature.estimator_hook = True | python | wandb/integration/tensorflow/estimator_hook.py | 27 | 33 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.