【人工智能笔记】第四十节:TF2实现VITGAN对抗生成网络,Siren网络 实现

SIREN深度解析:周期性激活函数如何革新隐式神经表示与连续信号重建 在计算机视觉与图形学领域,用神经网络直接拟合连续信号正成为替代传统离散化表示的重要范式。无论是图像超分、音频波形重建还是三维形状建模,本质上都要求模型能够从坐标映射到高保真数值,这对激活函数的表达能力和梯度传播特性提出了严苛要求。常见的ReLU激活因分段线性特性导致高阶导数丢失,难以捕捉高频细节。SIREN通过引入周期性正弦激活函数,并配套精心推导的初始化策略,使网络能够稳定传播任意阶梯度信号,从而以连续函数形式表征图像纹理、声音谐波与三维表面几何。这一技术已广泛渗透至神经辐射场、神经SDF、任意分辨率图像 阅读详情

网络结构图
该章节介绍VITGAN对抗生成网络中,Siren网络 部分的代码实现。

目录(文章发布后会补上链接):

  1. 网络结构简介
  2. Mapping NetWork 实现
  3. PositionalEmbedding 实现
  4. MLP 实现
  5. MSA多头注意力 实现
  6. SLN自调制 实现
  7. CoordinatesPositionalEmbedding 实现
  8. ModulatedLinear 实现
  9. Siren 实现
  10. Generator生成器 实现
  11. PatchEmbedding 实现
  12. ISN 实现
  13. Discriminator鉴别器 实现
  14. VITGAN 实现

Siren网络 简介

Generator生成器
论文原文
论文原文
Siren网络 是论文中资料46里提到的网络结构。

代码实现

原Siren网络实现:

import tensorflow as tf
import numpy as np


class SineLayer(tf.keras.layers.Layer):
    def __init__(
        self,
        emb_dim,
        use_bias=True,
        is_first=False,
        omega_0=30,
        demodulation=True,
        outermost_linear=False, 
    ):
        super().__init__()
        self.emb_dim = emb_dim
        self.use_bias = use_bias
        self.is_first = is_first
        self.omega_0 = omega_0
        self.demodulation = demodulation
        self.outermost_linear=outermost_linear
        kernel_initializer = None
        if is_first:
            kernel_initializer = tf.random_uniform_initializer(
                -1/emb_dim,
                1/emb_dim
            )
        else:
            kernel_initializer = tf.random_uniform_initializer(
                -np.sqrt(6 / emb_dim) / omega_0,
                np.sqrt(6 / emb_dim) / omega_0
            )
        self.linear = tf.keras.layers.Dense(
            units=emb_dim,
            use_bias=use_bias,
            kernel_initializer=kernel_initializer,
        )

    def call(self, x):
        x = self.linear(x)
        if self.outermost_linear:
            return x
        else:
            return tf.math.sin(self.omega_0 * x)


class Siren(tf.keras.layers.Layer):
    def __init__(
        self,
        hidden_dim,
        hidden_layers,
        out_dim,
        first_omega_0=30.0,
        hidden_omega_0=30.0,
        demodulation=True,
        outermost_linear=False,
        ):
        super().__init__()
        self.hidden_dim = hidden_dim
        self.hidden_layers = hidden_layers
        self.out_dim = out_dim
        self.first_omega_0=first_omega_0
        self.hidden_omega_0=hidden_omega_0
        self.demodulation=demodulation
        self.outermost_linear=outermost_linear
        self.net_layers = []
        self.net_layers.append(
            SineLayer(
                hidden_dim, 
                is_first=True,
                omega_0=first_omega_0,
                demodulation=demodulation,
            )
        )

        for _ in range(hidden_layers):
            self.net_layers.append(
                SineLayer(
                    hidden_dim, 
                    is_first=False,
                    omega_0=hidden_omega_0,
                    demodulation=demodulation,
                )
            )

        self.net_layers.append(
            SineLayer(
                out_dim,
                is_first=False,
                omega_0=hidden_omega_0,
                demodulation=demodulation,
                outermost_linear=outermost_linear,
            )
        )

    def call(self, x):
        for layer in self.net_layers:
            x = layer(x)
        return x



if __name__ == "__main__":
    emb_dim = 768 # 16*16*3
    layer = Siren(
        hidden_dim=emb_dim,
        hidden_layers=3,
        out_dim=3,
        first_omega_0=30.0,
        hidden_omega_0=30.0,
        demodulation=True,
        outermost_linear=False, 
    )
    # e_fou = tf.random.uniform([2*196,256,768], dtype=tf.float32)
    y = tf.random.uniform([2,196,768], dtype=tf.float32)
    o1 = layer(y)
    tf.print('o1:', tf.shape(o1))

原Siren网络 + ModulatedLinear 的实现:

import tensorflow as tf
import numpy as np
import sys

sys.path.append('')

from models.modulated_linear import ModulatedLinear


class SineLayer(tf.keras.layers.Layer):
    def __init__(
        self,
        hidden_dim,
        output_dim,
        use_bias=False,
        is_first=False,
        omega_0=30,
        demodulation=True,
        outermost_linear=False, 
    ):
        super().__init__()
        self.hidden_dim = hidden_dim
        self.output_dim = output_dim
        self.use_bias = use_bias
        self.is_first = is_first
        self.omega_0 = omega_0
        self.demodulation = demodulation
        self.outermost_linear=outermost_linear
        kernel_initializer = None
        if is_first:
            kernel_initializer = tf.random_uniform_initializer(
                -1/output_dim,
                1/output_dim
            )
        else:
            kernel_initializer = tf.random_uniform_initializer(
                -np.sqrt(6 / output_dim) / omega_0,
                np.sqrt(6 / output_dim) / omega_0
            )
        self.linear = ModulatedLinear(
            hidden_dim=hidden_dim,
            output_dim=output_dim,
            demodulation=demodulation,
            use_bias=use_bias,
            kernel_initializer=kernel_initializer,
        )

    def call(self, inputs):
        assert isinstance(inputs, tuple) and len(inputs) == 2
        x, style = inputs
        x = self.linear((x, style))
        if self.outermost_linear:
            return x
        else:
            return tf.math.sin(self.omega_0 * x)


class Siren(tf.keras.layers.Layer):
    def __init__(
        self,
        hidden_dim,
        hidden_layers,
        out_dim,
        first_omega_0=30.0,
        hidden_omega_0=30.0,
        demodulation=True,
        outermost_linear=False,
        ):
        super().__init__()
        self.hidden_dim = hidden_dim
        self.hidden_layers = hidden_layers
        self.out_dim = out_dim
        self.first_omega_0=first_omega_0
        self.hidden_omega_0=hidden_omega_0
        self.demodulation=demodulation
        self.outermost_linear=outermost_linear
        self.net_layers = []
        self.net_layers.append(
            SineLayer(
                hidden_dim=hidden_dim,
                output_dim=hidden_dim,
                is_first=True,
                omega_0=first_omega_0,
                demodulation=demodulation,
            )
        )

        for _ in range(hidden_layers):
            self.net_layers.append(
                SineLayer(
                    hidden_dim=hidden_dim,
                    output_dim=hidden_dim,
                    is_first=False,
                    omega_0=hidden_omega_0,
                    demodulation=demodulation,
                )
            )

        self.net_layers.append(
            SineLayer(
                hidden_dim=hidden_dim,
                output_dim=out_dim,
                is_first=False,
                omega_0=hidden_omega_0,
                demodulation=demodulation,
                outermost_linear=outermost_linear,
            )
        )

    def call(self, inputs):
        assert isinstance(inputs, tuple) and len(inputs) == 2
        x, style = inputs
        for layer in self.net_layers:
            x = layer((x, style))
        return x



if __name__ == "__main__":
    emb_dim = 768 # 16*16*3
    layer = Siren(
        hidden_dim=emb_dim,
        hidden_layers=3,
        out_dim=3,
        first_omega_0=30.0,
        hidden_omega_0=30.0,
        demodulation=True,
        outermost_linear=False, 
    )
    e_fou = tf.random.uniform([2*196,256,768], dtype=tf.float32)
    y = tf.random.uniform([2,196,768], dtype=tf.float32)
    o1 = layer((e_fou, y))
    tf.print('o1:', tf.shape(o1))

参考资料:

笔记1 SIREN Abstract Implicitly defined, continuous, differentiable signal representations parameterized by neural networks have emerged as a powerful paradigm, offering many possible benefits over conventional representations. However, current network architec 阅读详情

相关推荐

tf_SIREN:正弦表示网络(SIREN)的Tensorflow 2.0实现

Tensorflow正弦表示网络(SIREN) 基于的正弦表示网络(SIREN)的Tensorflow 2.0实现。 安装 点安装 $ pip install --upgrade tf_siren 点安装(测试支持) $ pip install --upgrade tf_siren[tests] 用法 对于等效于纸张的常规用法,请导入并使用SinusodialRepresentationDense或SIRENModel 。 from tf_siren import SinusodialRepresentationDense from tf_siren import SIRENModel # You can use SinusodialRepresentationDense exactly like you ordinarily use Dense layers. ip = tf .

【亲测免费】 探索SIREN:一种强大的神经网络框架

是由研究员Vsitzmann开发的一个基于PyTorch的神经网络框架,其全称为"Spatio-temporal Interpolative Reconstructive Neural Network"(时空插值重建神经网络)。SIREN旨在通过高阶正弦激活函数,实现对连续域(如空间、时间或者两者的组合)的数据进行高质量的插值和重构。 ## 技术分析 ### 高阶正弦激活函数 SIREN的核...

gitblog_00074的博客 2117

siren:正弦表示网络(SIREN)的PyTorch实施

正弦表示网络(SIREN) 从论文出发,正弦表示网络(SIREN)的非官方PyTorch实现。这个仓库是优秀的TF 2.0实现的PyTorch端口。 如果您在研究中使用此代码库,请使用以下引用: @software{aman_dalmia_2020_3902941, author = {Aman Dalmia}, title = {dalmia/siren}, month = jun, year = 2020, publisher = {Zenodo}, version = {v1.1}, doi = {10.5281/zenodo.3902941}, url = {https://doi.org/10.5281/zenodo.3902941} }

SIREN:使用周期性激活函数的隐式神经表示(论文解释)

这篇论文提出了一种新的神经网络模型,名为SIRENs(Sine-Activated Neural Networks),用于表示图像、声音、点云等信号。与传统的深度学习模型不同,SIRENs 将信号表示为一个函数,该函数将信号的坐标映射到其值。 论文作者首先介绍了SIRENs 的基本概念,即利用正弦函数作为神经网络的非线性激活函数,并通过仔细地初始化网络参数,使其能够很好地捕捉信号。 作者接着从机器...

YannicKilcher的博客 1114

51单片机矩阵键盘——LCD1602显示

矩阵键盘扫描(输入扫描) 原理:读取第1行(列)→读取第2行(列) →读取第3行(列) → ……,然后快速循环这个过程,最终实现所有按键同时检测的效果 在键盘中按键数量较多时,为了减少I/O口的占用,通常将按键排列成矩阵形式采用逐行或逐列的“扫描”,就可以读出任何位置按键的状态。

YLG_lin的博客 9854

超详细!动态规划详解分析(典型例题分析和对比,附源码)

为啥要使用动态规划?什么时候使用动态规划?以下是我的一些理解和心得,如果你感兴趣,就接着往下看吧。 对您有帮助的话记得给我点个赞哟! 动态规划的基本思想 动态规划(Dynamic Programming,DP)算法通常用于求解某种具有最优性质的问题。在这类问题中,可能会有许多可行解,每一个解都对应一个值,我们希望找到具有最优值的解。 动态规划算法与分治法类似,其基本思想也是将待求解的问题分解成若干个子问题,先求解子问题,然后从这些子问题的解中 得到原有问题的解。与分治法不同的是,动态规划经分解后得到的子问题

qq_44398094的博客 8万+

深度学习系列44. Siren和Deep-Daze模型

Siren就是用sin函数代替原先的激活函数(例如ReLU)首先定义一个sineLayer层,输出为sin(ω0f(x))sin(\omega_0f(x))sin(ω0​f(x)),其中f(x)为全连接层。

kittyzc的博客 1761

QKD(量子密钥分发)

量子密钥分发(Quantum Key Distribution,QKD)是一种基于量子力学原理的安全通信协议,它允许两个用户通过不安全的通信信道创建并共享一个安全的密钥。这个密钥随后可以用于加密和解密信息,确保通信的机密性。QKD的核心原理是量子不可克隆定理和量子测量的不确定性。

qq_40844444的博客 2896

【亲测免费】 探秘Siren-PyTorch:实现逼真3D重建的神奇工具

探秘Siren-PyTorch:实现逼真3D重建的神奇工具 在计算机视觉领域,3D模型的生成与重建是一项至关重要的任务,它广泛应用于游戏开发、虚拟现实、建筑设计等多个行业。今天我们要介绍的是一款名为的开源项目,它旨在利用PyTorch深度学习框架构建高质量的3D表面模型。 项目简介 Siren-PyTorch是由LucidRains开发的一个库,它基于一种称为“SIREN”(Sinusoidal ...

gitblog_00071的博客 705

20240128 C#与SCPI协议实战:轻量级仪器控制库ScpiNet应用指南

本文详细介绍了轻量级C#库ScpiNet在仪器控制中的应用。相较于传统的NI-VISA,ScpiNet无需安装庞大运行时,通过纯C#实现直接与USB或以太网设备通信,支持跨厂商SCPI仪器。文章提供了从快速连接到实战封装、错误处理的完整指南,帮助开发者构建简洁高效的自动化测试系统。

h9j8k7l6m5n的博客 548

中兴OLT配置实战:从零开始,手把手教你完成一个HGU的完整业务开通(含DBA模板、限速与远程升级)

本文详细介绍了中兴OLT配置实战,从零开始手把手教你完成HGU的完整业务开通,包括DBA模板设计、限速与远程升级等关键步骤。通过实际案例和详细命令,帮助工程师快速掌握GPON网络配置技巧,提升运维效率。

weixin_30599769的博客 349

【人工智能笔记】第四十一节:TF2实现VITGAN对抗生成网络,Generator生成器 实现

【人工智能笔记】第四十一节:TF2实现VITGAN对抗生成网络,Generator生成器 实现

不定时更新AI技术tensorflow实现方式,欢迎关注,有问题请私信我。 384

安全监控:人员行为分析_(2).人员行为分析基础理论

人员行为分析是指利用计算机视觉技术对视频中的人类行为进行实时或离线检测、识别和理解的过程。视频采集:通过摄像头等设备获取视频数据。视频预处理:对视频数据进行噪声过滤、图像增强等处理,以便后续分析。特征提取:从视频中提取出与人员行为相关的特征,如人体姿势、动作轨迹等。行为识别:利用机器学习或深度学习模型对提取的特征进行分类,识别出具体的人员行为。行为理解:对识别出的行为进行进一步分析,理解其背后的意图或状态。在人员行为分析中,常用的公开数据集包括UCF101、HMDB51、ActivityNet等。

zhubeibei168的博客 1345

探索深度学习的新境界:Sinusoidal Representation Networks(SIREN)

探索深度学习的新境界:Sinusoidal Representation Networks(SIREN) 在深度学习领域,寻找更加高效且表达能力强的神经网络结构一直是研究的热点。今天,我们来探索一个创新的技术——Sinusoidal Representation Networks(SIREN),它的出现重新定义了如何利用周期性激活函数构建隐式神经表示。 项目介绍 SIREN是基于论文《Implic...

gitblog_00520的博客 681

DDR5 的 PI: DIMM 上 PMIC,正在制造一批“新型 EMI 问题”

DDR5 的 PI,不再只是“供电设计”,而是一次“噪声管理设计”。电压稳定本地调节高频噪声EMI 风险系统不确定性DDR5 真正难的地方,不是跑起来,而是——在最差条件下,它还能不能一直跑。而 DIMM 上那颗 PMIC,正是你绕不开的关键角色。

weixin_43199439的博客 182

计算机组成原理(第三版)唐朔飞-第三章系统总线-课后习题

计算机组成原理(第三版)唐朔飞-第三章系统总线-课后习题

weixin_45735391的博客 6万+

别再死磕像素了!用PyTorch+SIREN玩转INR,5分钟让你的图像‘无限放大’

本文介绍了如何使用PyTorch和SIREN网络实现隐式神经表示(INR),实现图像的‘无限放大’。通过将图像视为连续函数,INR技术突破了传统像素阵列的限制,支持无损放大且显存需求低。文章详细讲解了环境准备、SIREN网络构建、训练技巧及效果对比,帮助开发者快速掌握这一前沿技术。

weixin_42532473的博客 250

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

10个必须掌握的隐式神经表示核心概念:理解SRN、MetaSDF和SIREN技术

隐式神经表示(Implicit Neural Representations, INR)正在彻底改变计算机视觉、图形学和机器学习领域!🎯 这种创新的信号参数化方法通过神经网络将连续坐标映射到信号值,为3D重建、图像生成和场景理解等任务带来了革命性的突破。本文将深入解析隐式神经表示的核心概念,帮助您快速掌握这一前沿技术。 ## 🔍 什么是隐式神经表示? 隐式神经表示是一种全新的信号参数化方式

gitblog_00783的博客 148

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

梯度起源网络(论文解释与实时编码)

这段文字主要介绍了一篇来自杜伦大学的论文,该论文提出了一种新的隐式生成模型,能够快速学习潜在表示,而无需显式编码器。 作者首先概述了论文的主题,并解释了为什么很多人对论文内容感到困惑。作者认为,论文利用了潜在变量的梯度来获取潜在编码,这是一种比较奇特的公式。 接下来,作者介绍了隐式生成模型的概念,尤其是论文中使用的SIREN(隐式表示网络)。SIREN 是一种神经网络,用于表示单个数据点,例如图像...

YannicKilcher的博客 457

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

第九周周报

第九周周报

童一的博客 790

【人工智能笔记】第二十节 efficientdet 目标检测模型,官方源码分析系列,BiFPN实现细节分析(二)

本章继续分析,BiFPN的实现部分。各种FPN结构如下: 如图,单个BiFPN有8个Node。在Efficientdet模型中,由如下类组成: FPNCells:按fpn_cell_repeats参数生成重复多个BiFPN。 FPNCell:代表单个BiFPN,包含8个Node。 FNode:将当前Node的多个输入融合,产生一个输出。 代码结构如下: FPNCells代码如下: class FPNCells(tf.keras.layers.Layer): .

不定时更新AI技术tensorflow实现方式,欢迎关注,有问题请私信我。 4033

Mask RCNN训练自己的数据集(修正及windows下使用labelme)

原文参考:https://blog.youkuaiyun.com/l297969586/article/details/79140840/ labelme编译并使用: 源码:https://github.com/tfwcn/labelme 源码已改成批量转Json的文件 Logs 2018/11/8 修改成自动保存到图片目录下到json文件夹中。需预先建立文件夹。 以前用过该工具的,请先删除C:...

不定时更新AI技术tensorflow实现方式,欢迎关注,有问题请私信我。 3111

MaskRCNN RPN网络分析

在每个锚生成5种大小和3种形状的候选框(每层特征对应一种大小,每个锚点对应3种形状)。并进行两层卷积后,做前景与背景的分类,与候选框的偏移量回归。与目标重叠&gt; = 0.7则为前景,与目标重叠&lt;= 0.3则为背景,其余框去掉。 ############################################################ # Region Propos...

不定时更新AI技术tensorflow实现方式,欢迎关注,有问题请私信我。 3019

jupyter 添加 Anaconda 环境

conda install notebook ipykernel # 添加环境,环境名为 py3 python -m ipykernel install --user --name py3 --display-name "Python (py3)"  

不定时更新AI技术tensorflow实现方式,欢迎关注,有问题请私信我。 2392

【人工智能笔记】第四节:基于TensorFlow 2.0实现CNN-RNN目标检测网络(自定义训练过程)

该文章使用WIDER FACE素材训练,下载地址: http://shuoyang1213.me/WIDERFACE/ 例子源码: https://github.com/tfwcn/AI/blob/master/CNN/face_detection.py 这次使用的网络由Encoder(编码器)与Decoder(解码器)组成。Encoder负责图片特征提取。再由Decoder循环输出...

不定时更新AI技术tensorflow实现方式,欢迎关注,有问题请私信我。 2314

【人工智能笔记】第二十七节 tensorflow 2.0 中保存模型的方式及注意事项

在 tensorflow2 中,保存模型有多种方法,方法都在tf.keras.models下面: 保存模型:save_model 或 model.save,读取模型:load_model。这里可保存成TensorFlow格式或者HDF5 文件。 只保存模型权重:model.save_weights,读取模型权重:model.load_weights。这里同样可以保存成TensorFlow格式或者HDF5 文件。 从配置读取模型结构:model.from_config(model.get_c...

不定时更新AI技术tensorflow实现方式,欢迎关注,有问题请私信我。 2302
上一篇: 【人工智能笔记】第三十九节:TF2实现VITGAN对抗生成网络,ModulatedLinear调制模块 实现
下一篇: 【微信小游戏开发笔记】第一节:微信小游戏Cocos开发环境配置
PPHT-H
博客等级 码龄18年 6254粉丝 84原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

PPHT-H

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值