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

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 
主站蜘蛛池模板: 会东县| 理塘县| 枣强县| 同仁县| 蓝山县| 东乡| 渝北区| 菏泽市| 海原县| 灵宝市| 阿勒泰市| 华坪县| 沧源| 阜南县| 琼结县| 平遥县| 嵊泗县| 招远市| 藁城市| 南涧| 大关县| 乌鲁木齐市| 昌图县| 孟村| 景泰县| 新竹市| 灵石县| 大埔县| 罗山县| 和平区| 梁河县| 珠海市| 安徽省| 五河县| 双柏县| 方正县| 东乡族自治县| 隆尧县| 柳州市| 永吉县| 巧家县|