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

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 
主站蜘蛛池模板: 都安| 太保市| 正定县| 光泽县| 南漳县| 崇仁县| 象山县| 洛扎县| 玉林市| 陵川县| 阳信县| 康保县| 海阳市| 民和| 普安县| 慈溪市| 诸暨市| 青海省| 米脂县| 蓝田县| 哈巴河县| 万州区| 剑川县| 沿河| 乐亭县| 金门县| 沙洋县| 江口县| 沂南县| 永城市| 健康| 县级市| 格尔木市| 门源| 临漳县| 敦化市| 和田市| 枣庄市| 昆明市| 读书| 临夏市|