# TFTF: TensorFlow TransFormer����
TensorFlow for everybody.
## Quick glance
```python
from tftf.layers import Layer, Dense, Activation
from tftf.models import Model
'''
Build model
'''
model = Model()
model.add(Dense(500, input_dim=784))
model.add(Activation('sigmoid'))
model.add(Dense(10))
model.add(Activation('softmax'))
model.compile()
model.describe()
'''
Train model
'''
model.fit(train_X, train_y)
'''
Test model
'''
print(model.accuracy(test_X, test_y))
```
See [examples](https://github.com/yusugomori/tftf/tree/master/examples) for other implementations.
## Installation
- **Install TFTF from PyPI (recommended):**
```sh
pip install tensorflow
pip install tftf
```
- **Alternatively: install TFTF from the GitHub source:**
First, clone TFTF using `git`:
```sh
git clone https://github.com/yusugomori/tftf.git
```
Then, `cd` to the TFTF folder and run the install command:
```sh
cd tftf
sudo python setup.py install
```
## Importable Layers, APIs
You can import low-level tftf APIs to your own TensorFlow implementations.
```python
from tftf.layers import Dense, Activation, NALU
from tftf import initializers as ini
from tftf import activations as act
from tftf import losses as loss
from tftf import optimizers as opt
from tftf.metrics import accuracy, f1
x = tf.placeholder(tf.float32, shape=[None, 784])
t = tf.placeholder(tf.float32, shape=[None, 10])
# import APIs
W = ini.glorot_normal([784, 200]) # or just write tf.Variable(...)
b = ini.zeros([200])
h = act.tanh(tf.matmul(x, W) + b) # or just write tf.nn.tanh(...)
# import Layers
h = Dense(200)(h)
h = Activation('tanh')(h)
h = NALU(200)(h)
W = ini.glorot_normal([200, 10])
b = ini.zeros([10])
y = act.softmax(tf.matmul(h, W) + b)
cost = loss.categorical_crossentropy(y, t)
train_step = opt.sgd(0.01).minimize(cost)
# Train
# ...
preds = y.eval(session=sess, feed_dict={x: test_X})
acc = accuracy(preds, test_y)
f = f1(preds, test_y)
print('accuracy: {:.3}'.format(acc))
print('f1: {:.3}'.format(f))
```
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
tftf-0.0.20.tar.gz (78个子文件)
tftf-0.0.20
PKG-INFO 1KB
tftf.egg-info
PKG-INFO 1KB
requires.txt 35B
SOURCES.txt 2KB
top_level.txt 5B
dependency_links.txt 1B
tftf
models
metrics
recall.py 348B
f1.py 324B
__init__.py 110B
precision.py 366B
accuracy.py 313B
Model.py 9KB
callbacks
EarlyStopping.py 565B
__init__.py 41B
optimizers
adadelta.py 105B
adam.py 122B
__init__.py 164B
sgd.py 93B
rmsprop.py 90B
adagrad.py 89B
momentum.py 148B
losses
categorical_crossentropy.py 231B
__init__.py 167B
mean_squared_error.py 116B
binary_crossentropy.py 358B
__init__.py 25B
metrics
__init__.py 39B
activations
__init__.py 43B
optimizers
__init__.py 42B
losses
__init__.py 38B
initializers
__init__.py 44B
__init__.py 92B
layers
RNN.py 3KB
Flatten.py 430B
GlobalAveragePooling2D.py 413B
activations
leaky_relu.py 100B
sigmoid.py 70B
linear.py 28B
softmax.py 70B
elu.py 62B
relu.py 64B
__init__.py 301B
tanh.py 64B
hard_sigmoid.py 106B
prelu.py 238B
swish.py 95B
selu.py 64B
NALU.py 1KB
Layer.py 3KB
initializers
glorot_normal.py 448B
zeros.py 170B
orthogonal.py 350B
glorot_uniform.py 614B
__init__.py 194B
normal.py 270B
ones.py 168B
Dense.py 948B
BatchNormalization.py 1KB
regularizers
l1_l2.py 329B
l2.py 243B
__init__.py 63B
l1.py 251B
NAC.py 1KB
LSTM.py 5KB
__init__.py 488B
Activation.py 571B
Conv2D.py 3KB
Dropout.py 494B
MaxPooling2D.py 2KB
modules
ResNet.py 3KB
Module.py 31B
__init__.py 54B
datasets
mnist.py 965B
Dataset.py 395B
__init__.py 30B
setup.cfg 38B
setup.py 1KB
README.md 2KB
共 78 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功