ΦFlow provides interactive user interfaces for live visualization and control. They allow you to see neural network predictions as the network is being trained or view training data while it is being generated.
The following interfaces are currently available:
The primary way to launch an interactive user interface is through
This function takes a number of
SampledField instances or variable names and shows them in a new UI.
from phi.flow import * data = Domain(x=32, y=32).scalar_grid(Noise()) view(data, gui=None)
gui=None (default) an appropriate interface is automatically selected based on the environment and installed packages.
Otherwise, the type of interface can be specified with
When the viewed data are batched, the GUI will try to plot all examples at once which may result in crowded plots.
This can be avoided using the
select keyword argument.
It specifies dimensions along which a single slice is displayed, e.g.
data = Domain(x=32, y=32).scalar_grid(Noise(batch=10, time=33)) view(batched_data, select='batch,time')
For each dimension, a slider will be added to the UI for the user to select which slice to display.
The GUI can be used to let the user control loop execution.
To do this, the user code needs to iterate over
data = Domain(x=32, y=32).scalar_grid(Noise()) for _ in view(data, play=False).range(10): data = physics(data)
Once the loop is encountered, the execution controls of the GUI can be used to pause execution, run single iterations or break the loop.
play=False, execution stops immediately once the loop is hit.
The GUI will update the displayed values either after each iteration, or at a configurable refresh rate.
The GUI can also be used to record the values of the viewed variables during loop execution.
Recording is enabled if the stop argument in
is named, e.g.
Then, the values for each viewed variable are accumulated and stacked along a new batch dimension with this name.
The recorded values can later be accessed through
data = Domain(x=32, y=32).scalar_grid(Noise()) viewer = view(data) for _ in viewer.range(frames=10): data = physics(data) all_data = viewer.rec.data # CenteredGrid (frames=11, x=32, y=32)
It is often useful to modify parameters while a script is running,
e.g. adjusting the learning rate to see which values work best.
This can be easily achieved using
learning_rate = control(0.001) checkpoint_interval = control(100, (1, 200))
control() returns the first argument which specifies the initial value.
learning_rate is a
float and can be used as such.
The value of the variable will be modified each time the user edits the value.
This can happen while the user code is running.
The following control types are supported:
floatwith a suitable value range
floatvalues with a large range or no range specified.
Additionally, buttons are generated for functions declared in the user script that take no parameters.