【神经网络结构可视化】PlotNeuralNet的安装、测试及创建自己的神经网络结构可视化图形

server/2024/10/22 14:28:42/

文章目录


前提准备

1、下载MikTeX

下载链接: MikTeX ( https://miktex.org/download )
在这里插入图片描述


2、下载Git bash

下载链接: Git bash ( https://git-scm.com/download/win )
在这里插入图片描述


PlotNeuralNet_17">3、下载PlotNeuralNet

下载链接: PlotNeuralNet ( https://github.com/HarisIqbal88/PlotNeuralNet?tab=readme-ov-file )
在这里插入图片描述


进行测试

PlotNeuralNetmasterzip_24">1、解压PlotNeuralNet-master.zip

将下载的PlotNeuralNet-master.zip解压到当前文件夹,并把解压的PlotNeuralNet-master文件夹更名为PlotNeuralNetPlotNeuralNet文件夹里的文件如下:
在这里插入图片描述


2、打开Git bash

  • PlotNeuralNet文件夹里空白处右击鼠标,找到Git Bash Here,点击进入。如下图所示:
    在这里插入图片描述
  • 输入以下命令在PlotNeuralNet文件夹创建一个新的文件夹my_project:
    mkdir my_project
  • 输入以下命令将Git bash 里的路径切换到文件夹my_project:
    cd my_project
  • 输入以下命令使用vim编写my_arch.py:
    vim my_arch.py
    在这里插入图片描述
  • 将以下代码复制进去
import sys
sys.path.append('../')
from pycore.tikzeng import *# defined your arch
arch = [to_head( '..' ),to_cor(),to_begin(),to_Conv("conv1", 512, 64, offset="(0,0,0)", to="(0,0,0)", height=64, depth=64, width=2 ),to_Pool("pool1", offset="(0,0,0)", to="(conv1-east)"),to_Conv("conv2", 128, 64, offset="(1,0,0)", to="(pool1-east)", height=32, depth=32, width=2 ),to_connection( "pool1", "conv2"),to_Pool("pool2", offset="(0,0,0)", to="(conv2-east)", height=28, depth=28, width=1),to_SoftMax("soft1", 10 ,"(3,0,0)", "(pool1-east)", caption="SOFT"  ),to_connection("pool2", "soft1"),to_end()]def main():namefile = str(sys.argv[0]).split('.')[0]to_generate(arch, namefile + '.tex' )if __name__ == '__main__':main()
  • 代码复制完后,按Esc键,然后再按:wq后回车保存退出。
    在这里插入图片描述
  • 执行以下命令
    bash ../tikzmake.sh my_arch
    在这里插入图片描述
  • 宏包安装
    在弹出的窗口界面安装宏包
    在这里插入图片描述
    【可能的报错】
    如果在Git bash 中输出以下报错:
    ! LaTeX Error: File ’import.sty‘ not found. Type X to quit or to proceed, or enter new name. (Default extension: sty) Enter file name:
    【解决方式】
    1、直接关闭Git bash
    2、找到并打开MikTex Console
    在这里插入图片描述
    3、按下图进行操作
    在这里插入图片描述
    4、执行以下命令
    bash ../tikzmake.sh my_arch
    在这里插入图片描述

3、 在my_project中查看生成的pdf文件

在这里插入图片描述
在这里插入图片描述


创建自己的神经网络结构可视化图形

找到pyexamples文件夹下的test_simple.py或unet.py文件,更改defined your arch部分,运行代码后会生成一个.tex文件,运行.tex文件即可得到自己的可视化模型的pdf文件。
test_simple.py中的defined your arch部分:

# defined your arch
arch = [to_head( '..' ),to_cor(),to_begin(),to_Conv("conv1", 512, 64, offset="(0,0,0)", to="(0,0,0)", height=64, depth=64, width=2 ),to_Pool("pool1", offset="(0,0,0)", to="(conv1-east)"),to_Conv("conv2", 128, 64, offset="(1,0,0)", to="(pool1-east)", height=32, depth=32, width=2 ),to_connection( "pool1", "conv2"), to_Pool("pool2", offset="(0,0,0)", to="(conv2-east)", height=28, depth=28, width=1),to_SoftMax("soft1", 10 ,"(3,0,0)", "(pool1-east)", caption="SOFT"  ),to_connection("pool2", "soft1"),    to_Sum("sum1", offset="(1.5,0,0)", to="(soft1-east)", radius=2.5, opacity=0.6),to_connection("soft1", "sum1"),to_end()]

unet.py中的defined your arch部分:

arch = [ to_head('..'), to_cor(),to_begin(),#inputto_input( '../examples/fcn8s/cats.jpg' ),#block-001to_ConvConvRelu( name='ccr_b1', s_filer=500, n_filer=(64,64), offset="(0,0,0)", to="(0,0,0)", width=(2,2), height=40, depth=40  ),to_Pool(name="pool_b1", offset="(0,0,0)", to="(ccr_b1-east)", width=1, height=32, depth=32, opacity=0.5),*block_2ConvPool( name='b2', botton='pool_b1', top='pool_b2', s_filer=256, n_filer=128, offset="(1,0,0)", size=(32,32,3.5), opacity=0.5 ),*block_2ConvPool( name='b3', botton='pool_b2', top='pool_b3', s_filer=128, n_filer=256, offset="(1,0,0)", size=(25,25,4.5), opacity=0.5 ),*block_2ConvPool( name='b4', botton='pool_b3', top='pool_b4', s_filer=64,  n_filer=512, offset="(1,0,0)", size=(16,16,5.5), opacity=0.5 ),#Bottleneck#block-005to_ConvConvRelu( name='ccr_b5', s_filer=32, n_filer=(1024,1024), offset="(2,0,0)", to="(pool_b4-east)", width=(8,8), height=8, depth=8, caption="Bottleneck"  ),to_connection( "pool_b4", "ccr_b5"),#Decoder*block_Unconv( name="b6", botton="ccr_b5", top='end_b6', s_filer=64,  n_filer=512, offset="(2.1,0,0)", size=(16,16,5.0), opacity=0.5 ),to_skip( of='ccr_b4', to='ccr_res_b6', pos=1.25),*block_Unconv( name="b7", botton="end_b6", top='end_b7', s_filer=128, n_filer=256, offset="(2.1,0,0)", size=(25,25,4.5), opacity=0.5 ),to_skip( of='ccr_b3', to='ccr_res_b7', pos=1.25),    *block_Unconv( name="b8", botton="end_b7", top='end_b8', s_filer=256, n_filer=128, offset="(2.1,0,0)", size=(32,32,3.5), opacity=0.5 ),to_skip( of='ccr_b2', to='ccr_res_b8', pos=1.25),    *block_Unconv( name="b9", botton="end_b8", top='end_b9', s_filer=512, n_filer=64,  offset="(2.1,0,0)", size=(40,40,2.5), opacity=0.5 ),to_skip( of='ccr_b1', to='ccr_res_b9', pos=1.25),to_ConvSoftMax( name="soft1", s_filer=512, offset="(0.75,0,0)", to="(end_b9-east)", width=1, height=40, depth=40, caption="SOFT" ),to_connection( "end_b9", "soft1"),to_end() ]

http://www.ppmy.cn/server/21555.html

相关文章

<计算机网络自顶向下> Internet Protocol(未完成)

互联网中的网络层 IP数据报格式 ver: 四个比特的版本号(IPV4 0100, IPV6 0110) headlen:head的长度(头部长度字段(IHL)指定了头部的长度,以32位字(4字节)为单位计算。这…

OSD图像技术

OSD(On-Screen Display)图像技术,是指在显示设备上叠加显示文字、图形或图像的功能。这项技术广泛应用于电视、电脑显示器、安防监控系统中的摄像头、以及其他各类显示界面中。 OSD允许用户在不干扰主画面内容的情况下,查看或调整…

vue 跳转页面打开浏览器新窗口或者打开新标签

vue 跳转页面打开浏览器新窗口或者打开新标签 打开浏览器新窗口方法: openNewWindow () {// 打开新窗口let left ((window.screen.width / 2) - 180) / 2 // 新窗口居中let width (window.screen.width / 2) 180 // 新窗口的宽度// 新窗口要设置的参数…

深度学习之图像分割从入门到精通——基于unet++实现细胞分割

模型 import torch from torch import nn__all__ [UNet, NestedUNet]class VGGBlock(nn.Module):def __init__(self, in_channels, middle_channels, out_channels):super().__init__()self.relu nn.ReLU(inplaceTrue)self.conv1 nn.Conv2d(in_channels, middle_channels, …

【Unity】苹果(IOS)开发证书保姆级申请教程

前言 我们在使用xcode出包的时候,需要用到iOS证书(.p12)和描述文件(.mobileprovision) 开发证书及对应的描述文件用于开发阶段使用,可以直接将 App 安装到手机上,一个描述文件最多绑定100台测试设备 1.证书管理 进入网站Apple Developer &…

三星电脑文件夹误删了怎么办?恢复方案在此

在使用三星电脑的过程中,我们可能会不小心删除了某个重要的文件夹,其中可能包含了工作文件、家庭照片、视频或其他珍贵的数据。面对这种突发情况,不必过于焦虑。本文将为您提供几种有效的恢复方案,希望能帮助您找回误删的文件夹及…

uniapp 引用组件后 不起作用 无效果 不显示

根据uniapp官方文档easycom组件规范 只要组件安装在项目的components目录下或uni_modules目录下,并符合components/组件名称/组件名称.(vue|uvue)目录结构(注意:当同时存在vue和uvue时,uni-app 项目优先使用 vue 文件,…

Java 基于Graphics2D 实现海报(支持自定义颜色,背景,logo,贴图)

效果: 海报一: 海报二: 代码: 参数实体类: package com.ly.cloud.dto;import lombok.Data;/*** Author * Date Created in 2024/4/24 下午2:16* DESCRIPTION: 海报页面所需的参数 实体类* Version V1.0*/ Dat…