基于 TensorFlow 的神经网络库 Sonnet

码农软件 · 软件分类 · 神经网络/人工智能 · 2019-10-14 18:57:39

软件介绍

Sonnet 库使用面向对象的方法,允许创建定义一些前向传导计算的模块。模块用一些输入 Tensor 调用,添加操作到图里并返回输出 Tensor。其中一种设计选择是通过在随后调用相同的模块时自动重用变量来确保变量分享被透明化处理。

在各类文献中,很多模型都可以被视为分层形式,如可微分神经计算机可能包含 LSTM 控制器,可以实现为包含标准线性层。

该库兼容 Linux/Mac OS X 和 Python 2.7。TensorFlow 的版本必须至少为 1.0.1。Sonnet 支持 TensorFlow 的 virtualenv 安装模式,以及 nativ pip 安装。

安装步骤

若想安装 Sonnet,你需要使用 bazel 依靠 TensorFlow 头文件对这个库进行编译。请按照指定步骤安装 TensorFlow

安装 BAZEL

请确保你拥有最新版本的 bazel(至少为 0.4.5 版),如果版本过旧,请遵循此步骤

Virtualenv TensorFlow 安装

如果你想使用 virtualenv,请在安装时急活你的 virtualenv,或跳过此步骤:

$ source $VIRTUALENV_PATH/bin/activate # bash, sh, ksh, or zsh
$ source $VIRTUALENV_PATH/bin/activate.csh # csh or tcsh

配置 TensorFlow 头文件

复制 Sonnet 和 TensorFlow 的源代码作为一个子模块:

$ git clone --recursive https://github.com/deepmind/sonnet

使用 configure:

$ cd sonnet/tensorflow
$ ./configure
$ cd ../

这一步是让 Sonnet 构建于 TensorFlow 头文件上的必要步骤。

构建和运行安装程序

运行安装脚本,在临时目录中创建一个 wheel file:

$ mkdir /tmp/sonnet
$ bazel build --config=opt :install
$ ./bazel-bin/install /tmp/sonnet

pip install 生成的 wheel file:

$ pip install /tmp/sonnet/*.whl

如果已安装 Sonnet,卸载 wheel file 上之前的 pip install :

$ pip uninstall sonnet

通过尝试重采样(resampler op)来验证 Sonnet 是否安装成功:

$ cd ~/
$ python>>> import sonnet as snt>>> import tensorflow as tf>>> snt.resampler(tf.constant([0.]), tf.constant([0.]))

预计输出:

<tf.Tensor 'resampler/Resampler:0' shape=(1,) dtype=float32>

如果引入了 ImportError,C++组件未找到时,请确保没有导入复制的源代码(即在复制的资源库外调用 Python),并在安装 wheel file 前卸载 Sonnet。

本文地址:https://codercto.com/soft/d/16760.html

The Algorithmic Beauty of Plants

The Algorithmic Beauty of Plants

Przemyslaw Prusinkiewicz、Aristid Lindenmayer / Springer / 1996-4-18 / USD 99.00

Now available in an affordable softcover edition, this classic in Springer's acclaimed Virtual Laboratory series is the first comprehensive account of the computer simulation of plant development. 150......一起来看看 《The Algorithmic Beauty of Plants》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

MD5 加密
MD5 加密

MD5 加密工具