• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mkofler96 / DeepSDFStruct / 18644067928

20 Oct 2025 06:24AM UTC coverage: 80.88% (+2.5%) from 78.42%
18644067928

push

github

mkofler96
removed gus plots from plotting and added log plot to training

294 of 354 branches covered (83.05%)

Branch coverage included in aggregate %.

2409 of 2988 relevant lines covered (80.62%)

0.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

64.52
DeepSDFStruct/deep_sdf/plotting.py
1
import numpy as np
1✔
2
import os
1✔
3
import logging
1✔
4
import torch
1✔
5
import matplotlib.pyplot as plt
1✔
6

7
import DeepSDFStruct.deep_sdf.workspace as ws
1✔
8

9

10
def extract_paths(data, current_path=""):
1✔
11
    paths = []
×
12

13
    if isinstance(data, dict):
×
14
        for key, value in data.items():
×
15
            new_path = f"{current_path}/{key}" if current_path else key
×
16
            paths.extend(extract_paths(value, new_path))
×
17

18
    elif isinstance(data, list):
×
19
        for item in data:
×
20
            paths.extend(extract_paths(item, current_path))
×
21

22
    else:
23
        paths.append(f"{current_path}/{data}")
×
24

25
    return paths
×
26

27

28
def running_mean(x, N):
1✔
29
    cumsum = np.cumsum(np.insert(x, 0, 0))
1✔
30
    return (cumsum[N:] - cumsum[:-N]) / float(N)
1✔
31

32

33
def plot_logs(experiment_directory, show_lr=False, ax=None, filename=None):
1✔
34

35
    logs = torch.load(os.path.join(experiment_directory, ws.logs_filename))
1✔
36

37
    logging.info("latest epoch is {}".format(logs["epoch"]))
1✔
38

39
    num_iters = len(logs["loss"])
1✔
40
    iters_per_epoch = num_iters / logs["epoch"]
1✔
41

42
    logging.info("{} iters per epoch".format(iters_per_epoch))
1✔
43

44
    smoothed_loss_41 = running_mean(logs["loss"], 41)
1✔
45

46
    show_plt = False
1✔
47

48
    if show_lr:
1✔
49
        if ax is None:
1✔
50
            fig, ax = plt.subplots(2, 1)
1✔
51
            fig.tight_layout()
1✔
52
            show_plt = True
1✔
53
    else:
54
        if ax is None:
×
55
            fig, ax = plt.subplots()
×
56
            show_plt = True
×
57
        ax = [ax]
×
58

59
    ax[0].plot(
1✔
60
        np.arange(num_iters) / iters_per_epoch,
61
        logs["loss"],
62
        "#82c6eb",
63
        np.arange(20, num_iters - 20) / iters_per_epoch,
64
        smoothed_loss_41,
65
        "#2a9edd",
66
    )
67

68
    ax[0].set(xlabel="Epoch", ylabel="Loss")
1✔
69
    ax[0].legend(["Loss", "Loss (Running Mean)", "Loss (Running Mean 41)"])
1✔
70

71
    if show_lr:
1✔
72
        combined_lrs = np.array(logs["learning_rate"])
1✔
73
        ax[1].plot(
1✔
74
            np.arange(combined_lrs.shape[0]),
75
            combined_lrs[:, 0],
76
            np.arange(combined_lrs.shape[0]),
77
            combined_lrs[:, 1],
78
        )
79
        ax[1].set(xlabel="Epoch", ylabel="Learning Rate")
1✔
80
        ax[1].legend(["Decoder", "Latent Vector"])
1✔
81

82
    for axis in ax:
1✔
83
        axis.grid()
1✔
84
    if filename is not None:
1✔
85
        plt.savefig(filename, bbox_inches="tight")
1✔
86
    elif show_plt:
×
87
        plt.show()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc