官术网_书友最值得收藏!

PrettyTensor

PrettyTensor provides a thin wrapper on top of TensorFlow. The objects provided by PrettyTensor support a chainable syntax to define neural networks. For example, a model could be created by chaining the layers as shown in the following code:

model = (X.
flatten().
fully_connected(10).
softmax_classifier(n_classes, labels=Y))

PrettyTensor can be installed in Python 3 with the following command:

pip3 install prettytensor

PrettyTensor offers a very lightweight and extensible interface in the form of a method named apply(). Any additional function can be chained to PrettyTensor objects using the .apply(function, arguments) method. PrettyTensor will call the function and supply the current tensor as the first argument to the function.

User-created functions can be added using the @prettytensor.register decorator. Details can be found at https://github.com/google/prettytensor.

The workflow to define and train models in PrettyTensor is as follows:

  1. Get the data.
  2. Define hyperparameters and parameters.
  3. Define the inputs and outputs.
  4. Define the model.
  5. Define the evaluator, optimizer, and trainer functions.
  6. Create the runner object.
  7. Within a TensorFlow session, train the model with the runner.train_model() method.
  8. Within the same session, evaluate the model with the runner.evaluate_model() method.

The complete code for the PrettyTensor MNIST classification example is provided in the notebook ch-02_TF_High_Level_LibrariesThe output from the PrettyTensor MNIST example is as follows:

[1] [2.5561881]
[600] [0.3553167]
Accuracy after 1 epochs 0.8799999952316284 

[601] [0.47775066]
[1200] [0.34739292]
Accuracy after 2 epochs 0.8999999761581421 

[1201] [0.19110668]
[1800] [0.17418651]
Accuracy after 3 epochs 0.8999999761581421 

[1801] [0.27229539]
[2400] [0.34908807]
Accuracy after 4 epochs 0.8700000047683716 

[2401] [0.40000191]
[3000] [0.30816519]
Accuracy after 5 epochs 0.8999999761581421 

[3001] [0.29905257]
[3600] [0.41590339]
Accuracy after 6 epochs 0.8899999856948853 

[3601] [0.32594997]
[4200] [0.36930788]
Accuracy after 7 epochs 0.8899999856948853 

[4201] [0.26780865]
[4800] [0.2911002]
Accuracy after 8 epochs 0.8899999856948853 

[4801] [0.36304188]
[5400] [0.39880857]
Accuracy after 9 epochs 0.8999999761581421 

[5401] [0.1339224]
[6000] [0.14993289]
Accuracy after 10 epochs 0.8899999856948853 
主站蜘蛛池模板: 濉溪县| 海伦市| 黄石市| 法库县| 尚义县| 延长县| 玛纳斯县| 馆陶县| 德阳市| 拜城县| 墨玉县| 于都县| 潞西市| 鱼台县| 罗定市| 浦江县| 上林县| 宁蒗| 怀集县| 文登市| 奇台县| 疏勒县| 长白| 汉阴县| 徐闻县| 增城市| 成武县| 焉耆| 讷河市| 靖安县| 福清市| 扶沟县| 始兴县| 乌恰县| 阜康市| 贵港市| 磴口县| 茂名市| 静海县| 民勤县| 明水县|