Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create multiple plots in a single operation #1975

Closed
brollb opened this issue Nov 10, 2020 · 2 comments
Closed

Create multiple plots in a single operation #1975

brollb opened this issue Nov 10, 2020 · 2 comments
Assignees
Labels
bug job feedback Graphs, images, and other feedback generated during job execution.

Comments

@brollb
Copy link
Contributor

brollb commented Nov 10, 2020

Currently, this does not appear to be supported...

@brollb brollb added bug job feedback Graphs, images, and other feedback generated during job execution. labels Nov 10, 2020
@umesh-timalsina umesh-timalsina self-assigned this Nov 10, 2020
@brollb
Copy link
Contributor Author

brollb commented Nov 10, 2020

This is the code that I was running and expecting to see two plots generated:

from matplotlib import pyplot as plt 
from tensorflow.keras.optimizers import Adam

class TrainNodePredictor():
    def __init__(self, model, learning_rate=0.005, epochs=50):
        self.model = model
        self.epochs = epochs
        self.learning_rate = learning_rate
    def execute(self, data, val_data):
        optimizer = Adam(lr=self.learning_rate)
        self.model.compile(optimizer=optimizer, loss='categorical_crossentropy', weighted_metrics=['acc'])
        self.model.summary()
        X, A, y = data
        val_X, val_A, val_y = val_data
        val_data = ([val_X, val_A], val_y)
        unknowns = X.argmin(2)
        history = self.model.fit([X, A],
                        y,
                        sample_weight=unknowns,
                        epochs=self.epochs,
                        validation_data=val_data,
                        shuffle=True)
        plt.figure(0)
        plt.plot(history.history['acc'], label='train')
        plt.plot(history.history['val_acc'], label='val')
        plt.title('Accuracy')
        plt.xlabel('epoch')
        plt.ylabel('accuracy')
        plt.legend(['train', 'val'])
        plt.show()

        plt.figure(1)
        plt.plot(history.history['loss'], label='train')
        plt.plot(history.history['val_loss'], label='val')
        plt.title('Loss')
        plt.xlabel('epoch')
        plt.ylabel('loss')
        plt.legend(['train', 'val'])
        plt.show()
        return self.model

@umesh-timalsina
Copy link
Contributor

umesh-timalsina commented Nov 10, 2020

This needs a fix in upstream webgme-plotly, opening an issue there.

The above comment is not correct. The widget already handles array of PlotlyJSONs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug job feedback Graphs, images, and other feedback generated during job execution.
Projects
None yet
Development

No branches or pull requests

2 participants