graph_view#

scikitplot.visualkeras.graph_view(model, to_file=None, color_map=None, node_size=50, background_fill='white', padding=10, layer_spacing=250, node_spacing=10, connector_fill='gray', connector_width=1, ellipsize_after=10, inout_as_tensor=True, show_neurons=True)[source]#

Generates an architectural visualization for a given linear Keras tf.keras.Model model (i.e., one input and output tensor for each layer) in graph style.

Parameters:
modeltensorflow.keras.Model

A Keras tf.keras.Model model to be visualized.

to_filestr or None

Path to the file where the generated image will be saved. The file type is inferred from the file extension. If None, no file is created.

color_mapdict

A dictionary defining the fill and outline colors for each layer type. Layers not specified will use default colors.

node_sizeint

Size (in pixels) of each node in the visualization.

background_fillstr or tuple

Background color of the image. Can be a string or a tuple (R, G, B, A).

paddingint

Distance (in pixels) before the first and after the last layer in the visualization.

layer_spacingint

Horizontal spacing (in pixels) between consecutive layers.

node_spacingint

Horizontal spacing (in pixels) between nodes within a layer.

connector_fillstr or tuple

Color of the connectors. Can be a string or a tuple (R, G, B, A).

connector_widthint

Line width (in pixels) of the connectors between nodes.

ellipsize_afterint

Maximum number of neurons per layer to draw. Layers exceeding this limit will represent the remaining neurons as ellipses.

inout_as_tensorbool

If True, one input and output node will be created for each tensor. If False, tensors will be flattened, and one node for each scalar will be created (e.g., a tensor with shape (10, 10) will be represented by 100 nodes).

show_neuronsbool

If True, each neuron in supported layers will be represented as a node (subject to ellipsize_after limit). If False, each layer is represented by a single node.

Returns:
image

The generated architecture visualization image.

Parameters:
  • to_file (str)

  • color_map (dict)

  • node_size (int)

  • background_fill (Any)

  • padding (int)

  • layer_spacing (int)

  • node_spacing (int)

  • connector_fill (Any)

  • connector_width (int)

  • ellipsize_after (int)

  • inout_as_tensor (bool)

  • show_neurons (bool)

Return type:

<module ‘PIL.Image’ from ‘/opt/conda/lib/python3.11/site-packages/PIL/Image.py’>