neuromancer.plot module

Various helper functions for plotting.

class neuromancer.plot.Animator(dynamics_model)[source]

Bases: object

find_mat(model)[source]
make_and_save(filename)[source]
class neuromancer.plot.Visualizer[source]

Bases: object

eval(outputs)[source]
train_output()[source]
train_plot(outputs, epochs)[source]
class neuromancer.plot.VisualizerClosedLoop(u_key='U_pred_policy', y_key='Y_pred_dynamics', r_key='Rf', d_key=None, ymin_key=None, ymax_key=None, umin_key=None, umax_key=None, policy=None, ctrl_outputs=None, savedir='test_control')[source]

Bases: Visualizer

eval(outputs, plot_weights=False, figname='CL_control.png')[source]
plot_matrix()[source]
class neuromancer.plot.VisualizerDobleIntegrator(dataset, model, policy, dynamics, verbosity, savedir, nstep=40, x0=array([[1.5], [1.5]]), training_visuals=False, trace_movie=False)[source]

Bases: Visualizer

custom visualizer for double integrator example

eval(trainer)[source]
train_output(trainer, epoch_policy)[source]

visualize evolution of closed-loop contro and policy landscape during training :return:

class neuromancer.plot.VisualizerOpen(model, verbosity, savedir, training_visuals=False, trace_movie=False, figname=None)[source]

Bases: Visualizer

eval(outputs)[source]
Parameters:

outputs

Returns:

plot_matrix()[source]
plot_traj(true_traj, pred_traj, figname='open_loop.png')[source]
train_output()[source]
Returns:

train_plot(outputs, epoch)[source]
Parameters:
  • outputs

  • epoch

Returns:

class neuromancer.plot.VisualizerTrajectories(model, plot_keys, verbosity)[source]

Bases: Visualizer

eval(outputs)[source]
class neuromancer.plot.VisualizerUncertaintyOpen(dataset, savedir, dynamics_name='dynamics')[source]

Bases: Visualizer

eval(outputs)[source]
Parameters:

outputs

Returns:

plot_traj(true_traj, pred_traj, pred_mean, pred_std, figname='open_loop.png')[source]
neuromancer.plot.cl_simulate(A, B, net, nstep=50, x0=array([[1.], [1.]]))[source]
Parameters:
  • A

  • B

  • net

  • nstep

  • x0

Returns:

neuromancer.plot.get_colors(k)[source]

Returns k colors evenly spaced across the color wheel. :param k: (int) Number of colors you want. :return: (np.array, shape=[k, 3])

neuromancer.plot.plot_cl(X, U, nstep=50, save_path=None, trace_movie=False)[source]
neuromancer.plot.plot_cl_train(X_list, U_list, nstep=50, save_path=None)[source]
neuromancer.plot.plot_loss_DPC(model, policy, A, B, dataset, xmin=-5, xmax=5, save_path=None)[source]

plot loss function for trained DPC model :param model: :param dataset: :param xmin: :param xmax: :param save_path: :return:

neuromancer.plot.plot_loss_mpp(model, dataset, xmin=-2, xmax=2, save_path=None)[source]

plots loss function for multiparametric problem with 2 parameters :param model: :param dataset: :param xmin: :param xmax: :param save_path: :return:

neuromancer.plot.plot_matrices(matrices, labels, figname)[source]

Plots and saves figure of a grid of matrices. Useful for inspecting layers of weights of neural networks.

Parameters:
  • matrices – (list of lists of 2-way np.arrays) Grid of matrices to plot

  • labels – (list of lists of str) Labels for plotted matrices

  • figname – (str) Figure name ending with file extension of filetype to save as.

>>> import neuromancer.plot as plot
>>> color_matrices = [[get_colors(k*j) for k in range(2, 4)] for j in range(8, 11)]
>>> labels = [[f'{k*j} X 3 matrix' for k in range(2, 4)] for j in range(8, 11)]
>>> plot_matrices(color_matrices, labels, 'matrix_grid.png')
neuromancer.plot.plot_model_graph(model, data_keys, include_objectives=True, fname='model_graph.png')[source]
neuromancer.plot.plot_policy(net, xmin=-5, xmax=5, save_path=None)[source]
neuromancer.plot.plot_policy_train(A, B, policy, policy_list, xmin=-5, xmax=5, save_path=None)[source]
neuromancer.plot.plot_solution_mpp(model, xmin=-2, xmax=2, save_path=None)[source]

plots solution landscape for problem with 2 parameters and 1 decision variable :param net: :param xmin: :param xmax: :param save_path: :return:

neuromancer.plot.plot_traj(data, figname=None)[source]
Parameters:
  • data – (dict {str: np.array}) Dictionary of labels and time series

  • figname – (str)

neuromancer.plot.plot_trajectories(traj1, traj2, labels, figname)[source]
neuromancer.plot.pltCL(Y, R=None, U=None, D=None, X=None, ctrl_outputs=None, Ymin=None, Ymax=None, Umin=None, Umax=None, figname=None)[source]

plot input output closed loop dataset

neuromancer.plot.pltCorrelate(X, figname=None)[source]

plot correlation matrices of time series data

neuromancer.plot.pltOL(Y, Ytrain=None, U=None, D=None, X=None, figname=None)[source]

plot trained open loop dataset

neuromancer.plot.pltPhase(X, figname=None)[source]
Parameters:
  • X – (np.array, shape=[numpoints, {2,3}])

  • figname – (str) Filename for plot with extension for file type.

plot phase space for 2D and 3D state spaces

>> import numpy as np
>> import neuromancer.plot as plot
>> x = np.stack([np.linspace(-10, 10, 100)]*100)
>> y = np.stack([np.linspace(-10, 10, 100)]*100).T
>> z = x**2 + y**2
>> xyz = np.stack([x.flatten(), y.flatten(), z.flatten()])
>> plot.pltPhase(xyz, figname='phase.png')
neuromancer.plot.pltRecurrence(X, figname=None)[source]

plot recurrence of time series data

neuromancer.plot.trajectory_movie(true_traj, pred_traj, figname='traj.mp4', freq=1, fps=15, dpi=100)[source]