Matplotlib drawing, please can you set the subscript to start at 1 instead of 36

def plot_embeddings(embeddings, label,dataset_name,epoch):
    len_embedding = len(embeddings)
    emb_list = np.array(embeddings.tolist())
    label = np.array(label.tolist())

    color_idx = {}
    for i in range(len_embedding):
        color_idx.setdefault(label[i], [])
        color_idx[label[i]].append(i)

    fig, ax = plt.subplots(figsize=(20,10), dpi= 120)
    for c, idx in color_idx.items():
        ax.scatter(emb_list[idx, 0], emb_list[idx, 1], label=c)

    wandb.log({f"visualization/Embedding——{dataset_name}": fig,
               f"visualization/epoch": epoch,
               })

Hi @moailaozi , happy to help. From the screenshot provided this indicates that you began logging your charts at step 36. When executing your code did you make previous wandb.log calls in your script prior to creating the charts above? With every call to log(), wandb monotonically increase the step value. I checked one of your other projects and you were successful in logging similar charts that began at step 1 of the slider. More on bundle metrics into the same log() call here. Please let me know if you have any questions.

Thank you for your reply, but I still can’t solve this problem. I tried the following methods but nothing worked.

1:

    with wandb.init(project=project_name,config=args,name= model_name):
        # define our custom x axis metric
        wandb.define_metric("visualization/epoch")
        # define which metrics will be plotted against it
        wandb.define_metric(f"visualization/T-SNE——{args.target_dataset_name}", step_metric="visualization/epoch")
        wandb.define_metric(f"visualization/Embedding——{args.target_dataset_name}", step_metric="visualization/epoch")
        train(model_name,args)

2:

def plot_embeddings(embeddings, label,dataset_name,epoch):
    len_embedding = len(embeddings)
    emb_list = np.array(embeddings.tolist())
    label = np.array(label.tolist())

    color_idx = {}
    for i in range(len_embedding):
        color_idx.setdefault(label[i], [])
        color_idx[label[i]].append(i)

    fig, ax = plt.subplots(figsize=(20,10), dpi= 120)
    for c, idx in color_idx.items():
        ax.scatter(emb_list[idx, 0], emb_list[idx, 1], label=c)

    wandb.log({f"visualization/Embedding——{dataset_name}": fig,
               "visualization/epoch": epoch
               })
    return

By changing the coordinates, it still doesn’t change the index

Hi @moailaozi , thank you for providing a code example. There isn’t a specific issue with your functions, but rather I believe you are not nesting your log calls. I reviewed a recent project and noticed the following. Three of your visualizations begin at different steps. This is due to when creating each visualization you either did not initialize a new wandb run, or you logged each one with separate log calls. As mentioned above, With every call to log() , wandb monotonically increase the step value.

To prevent unintended behavior with logging steps, we recommend you nest your log calls. e.g wandb.log({"Viz1": <vizualization-logic>, "Viz2": <vizualization-logic>). This ensures with every log call the graphs step are incremented together.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.