作者:手机用户2602933971 | 来源:互联网 | 2023-10-15 17:51
可视化神经网络的网络结构并保存#导入基础包和方法#LoadlibrariesfromkerasimportmodelsfromkerasimportlayersfromIP
可视化神经网络的网络结构并保存
#导入基础包和方法
# Load libraries
from keras import models
from keras import layers
from IPython.display import SVG
from keras.utils.vis_utils import model_to_dot
from keras.utils import plot_model
#构建网络结构
# Start neural network
network = models.Sequential()# Add fully connected layer with a ReLU activation function
network.add(layers.Dense(units=16, activation='relu', input_shape=(10,)))# Add fully connected layer with a ReLU activation function
network.add(layers.Dense(units=16, activation='relu'))# Add fully connected layer with a sigmoid activation function
network.add(layers.Dense(units=1, activation='sigmoid'))
#可视化网络结构
# Visualize network architecture
SVG(model_to_dot(network, show_shapes=True