超强干货!TensorFlow易用代码大集合...

2 月 20 日 机器学习算法与Python学习

摘自机器之心

实际上,在我们搭建自己的模型或系统时,复制并粘贴这些代码就行了。它们以规范的形式定义不同的功能模块,因此只要修改少量参数与代码,它们就能完美地融入到我们项目中。


项目链接https://github.com/taki0112/Tensorflow-Cookbook


在这个项目中,作者重点突出这是一份易于使用的 TensorFlow 代码集,它包括常见的正则化、卷积运算和架构模块等代码。该项目包含一般深度学习架构所需要的代码,例如初始化和正则化、各种卷积运算、基本网络架构与模块、损失函数和其它数据预处理过程。此外,还特别增加了对 GAN 的支持,这主要体现在损失函数上,其中生成器损失和判别器损失可以使用推土机距离、最小二乘距离和 KL 散度等。


使用方法其实有两种,首先我们可以复制粘贴代码,这样对于模块的定制化非常有利。其次我们可以直接像使用 API 那样调用操作与模块,这种方法会使模型显得非常简洁,而且导入的源码也通俗易懂。首先对于第二种直接导入的方法,我们可以从 ops.py 和 utils.py 文件分别导入模型运算部分与图像预处理过程。


  • from ops import *

  • from utils import *


from ops import conv

x = conv(x, channels=64, kernel=3, stride=2, pad=1, pad_type= reflect , use_bias=True, sn=True, scope= conv )


而对于第一种复制粘贴,我们可能会根据实际修改一些参数与结构,但这要比从头写简单多了。如下所示,对于一般的神经网络,它会采用如下结构模板:


def network(x, is_training=True, reuse=False, scope="network"):
    with tf.variable_scope(scope, reuse=reuse):
        x = conv(...)

        ...return logit


其实深度神经网络就像一块块积木,我们按照上面的模板把 ops.py 中不同的模块堆叠起来,最终就能得到完整的前向传播过程。


代码集目录


项目页面:https://www.notion.so/Simple-Tensorflow-Cookbook-6f4563d0cd7343cb9d1e60cd1698b54d


目前整个项目包含 20 种代码块,它们可用于快速搭建深度学习模型:


推荐阅读

秘籍 | Python高效编程技巧

史上最污技术解读,让你秒懂IT术语

汇总 | 机器学习算法优缺点 & 如何选择

逃离数学焦虑、算法选择,思考做好机器学习项目的3个核心问题

15亿参数!史上最强通用NLP模型诞生:狂揽7大数据集最佳纪录

滴滴官宣裁员,2019年的滴滴你怎么看?

登录查看更多
点赞 0

In recent years, (retro-)digitizing paper-based files became a major undertaking for private and public archives as well as an important task in electronic mailroom applications. As a first step, the workflow involves scanning and Optical Character Recognition (OCR) of documents. Preservation of document contexts of single page scans is a major requirement in this context. To facilitate workflows involving very large amounts of paper scans, page stream segmentation (PSS) is the task to automatically separate a stream of scanned images into multi-page documents. In a digitization project together with a German federal archive, we developed a novel approach based on convolutional neural networks (CNN) combining image and text features to achieve optimal document separation results. Evaluation shows that our PSS architecture achieves an accuracy up to 93 % which can be regarded as a new state-of-the-art for this task.

点赞 0
阅读1+

Corrado B\"ohm once observed that if $Y$ is any fixed point combinator (fpc), then $Y(\lambda yx.x(yx))$ is again fpc. He thus discovered the first "fpc generating scheme" -- a generic way to build new fpcs from old. Continuing this idea, define an \emph{fpc generator} to be any sequence of terms $G_1,\dots,G_n$ such that $$Y \text{ is fpc } \Longrightarrow YG_1\cdots G_n \text{ is fpc}$$ In this contribution, we take first steps in studying the structure of (weak) fpc generators. We isolate several classes of such generators, and examine elementary properties like injectivity and constancy. We provide sufficient conditions for existence of fixed points of a given generator $(G_1,..,G_n)$: an fpc $Y$ such that $Y = YG_1\cdots G_n$. We conjecture that weak constancy is a necessary condition for existence of such (higher-order) fixed points. This generalizes Statman's conjecture on the non-existence of ``double fpcs'': fixed points of the generator $(G) = (\lambda yx.x(yx))$ discovered by B\"ohm.

点赞 0
阅读1+
Top