{"id":79844,"date":"2026-03-03T09:25:51","date_gmt":"2026-03-03T01:25:51","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/79844.html"},"modified":"2026-03-03T09:25:51","modified_gmt":"2026-03-03T01:25:51","slug":"%e4%bd%bf%e7%94%a8-visualdl-%e5%8f%af%e8%a7%86%e5%8c%96%e6%a8%a1%e5%9e%8b%ef%bc%8c%e6%95%b0%e6%8d%ae%e5%92%8c%e8%ae%ad%e7%bb%83","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/79844.html","title":{"rendered":"\u4f7f\u7528 VisualDL \u53ef\u89c6\u5316\u6a21\u578b\uff0c\u6570\u636e\u548c\u8bad\u7ec3"},"content":{"rendered":"<h2>\u4f7f\u7528 VisualDL \u53ef\u89c6\u5316\u6a21\u578b&#xff0c;\u6570\u636e\u548c\u8bad\u7ec3<\/h2>\n<p>\u5728\u6784\u5efa\u624b\u5199\u6570\u5b57\u8bc6\u522b\u6a21\u578b\u6559\u5b66\u6848\u4f8b\u4e2d&#xff0c;\u4ecb\u7ecd\u4e86\u5982\u4f55\u4f7f\u7528\u98de\u6868\u7684 paddle.io \u8fdb\u884c\u6570\u636e\u5904\u7406&#xff0c;\u901a\u8fc7 paddle.nn \u6784\u5efa\u6a21\u578b&#xff0c;\u4ee5\u53ca\u5982\u4f55\u5728\u8bad\u7ec3\u6570\u636e\u4e0a\u8fdb\u884c\u6a21\u578b\u7684\u8bad\u7ec3\u548c\u5728\u6d4b\u8bd5\u6570\u636e\u4e0a\u5bf9\u6a21\u578b\u6548\u679c\u8fdb\u884c\u8bc4\u4f30\u3002\u4e3a\u4e86\u4e86\u89e3\u6a21\u578b\u7684\u8bad\u7ec3\u8fc7\u7a0b&#xff0c;\u4e4b\u524d\u901a\u8fc7\u6253\u5370\u635f\u5931\u51fd\u6570 loss \u7684\u503c\u6765\u89c2\u5bdf\u53d1\u751f\u7684\u53d8\u5316&#xff0c;\u4f46\u662f\u8fd9\u79cd\u89c2\u6d4b\u65b9\u5f0f\u975e\u5e38\u4e0d\u76f4\u89c2\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528\u98de\u6868\u7684\u53ef\u89c6\u5316\u5de5\u5177 VisualDL \u6765\u63d0\u9ad8\u8bad\u7ec3\u795e\u7ecf\u7f51\u7edc\u7684\u4f53\u9a8c\u3002<\/p>\n<p>\u5728\u672c\u6559\u7a0b\u4e2d&#xff0c;\u53ef\u4ee5\u5b66\u4e60&#xff1a;<\/p>\n<li>\n<p>\u8bbe\u7f6e VisualDL<\/p>\n<\/li>\n<li>\n<p>\u5199\u5165\u6570\u636e\u5e76\u53ef\u89c6\u5316<\/p>\n<\/li>\n<p>\u5177\u4f53\u6765\u8bf4&#xff0c;\u5728\u7b2c 2 \u70b9\u53ef\u4ee5\u770b\u5230&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5982\u4f55\u68c0\u67e5\u8bad\u7ec3\u6570\u636e<\/p>\n<\/li>\n<li>\n<p>\u5728\u8bad\u7ec3\u6a21\u578b\u65f6\u5982\u4f55\u8ddf\u8e2a\u5176\u8868\u73b0<\/p>\n<\/li>\n<li>\n<p>\u5728\u8bad\u7ec3\u540e\u5982\u4f55\u8bc4\u4f30\u6a21\u578b\u7684\u8868\u73b0<\/p>\n<\/li>\n<\/ul>\n<p>\u672c\u6559\u7a0b\u57fa\u4e8e\u524d\u6587\u201c\u6784\u5efa\u624b\u5199\u6570\u5b57\u8bc6\u522b\u6a21\u578b\u201d\u6848\u4f8b\u7684\u6837\u677f\u4ee3\u7801\u8fdb\u884c\u8bf4\u660e\u3002\u8be5\u6848\u4f8b\u7684\u8be6\u7ec6\u8bb2\u89e3&#xff0c;\u8bf7\u53c2\u8003\u201c\u5341\u5206\u949f\u5feb\u901f\u4e0a\u624b\u98de\u6868\u201d\u3002<\/p>\n<p>import os<br \/>\nimport random<\/p>\n<p>import numpy as np<br \/>\n# \u52a0\u8f7d\u98de\u6868\u76f8\u5173\u5e93<br \/>\nimport paddle<br \/>\nfrom paddle.nn import Conv2D, MaxPool2D, Linear<br \/>\nimport paddle.nn.functional as F<\/p>\n<p># \u6570\u636e\u8f7d\u5165<br \/>\nclass MNISTDataset():<br \/>\n  def __init__(self, mode&#061;&#039;train&#039;):<br \/>\n    self.mnist_data &#061; paddle.vision.datasets.MNIST(mode&#061;mode)<\/p>\n<p>  def __getitem__(self, idx):<br \/>\n    data, label &#061; self.mnist_data[idx]<br \/>\n    data &#061; np.reshape(data, [1, 28, 28]).astype(&#039;float32&#039;) \/ 255<br \/>\n    label &#061; np.reshape(label, [1]).astype(&#039;int64&#039;)<br \/>\n    return (data, label)<\/p>\n<p>  def __len__(self):<br \/>\n    return len(self.mnist_data)<\/p>\n<p>train_loader &#061; paddle.io.DataLoader(MNISTDataset(mode&#061;&#039;train&#039;),<br \/>\n                                    batch_size&#061;16,<br \/>\n                                    shuffle&#061;True)<\/p>\n<p>test_loader &#061; paddle.io.DataLoader(MNISTDataset(mode&#061;&#039;test&#039;),<br \/>\n                                    batch_size&#061;16,<br \/>\n                                    shuffle&#061;False)<\/p>\n<p># \u5b9a\u4e49 mnist \u6570\u636e\u8bc6\u522b\u7f51\u7edc\u6a21\u578b\u7ed3\u6784<br \/>\nclass MNIST(paddle.nn.Layer):<br \/>\n     def __init__(self):<br \/>\n         super().__init__()<\/p>\n<p>         # \u5b9a\u4e49\u5377\u79ef\u5c42&#xff0c;\u8f93\u51fa\u7279\u5f81\u901a\u9053 out_channels \u8bbe\u7f6e\u4e3a 20&#xff0c;\u5377\u79ef\u6838\u7684\u5927\u5c0f kernel_size \u4e3a 5&#xff0c;\u5377\u79ef\u6b65\u957f stride&#061;1&#xff0c;padding&#061;2<br \/>\n         self.conv1 &#061; Conv2D(in_channels&#061;1, out_channels&#061;20, kernel_size&#061;5, stride&#061;1, padding&#061;2)<br \/>\n         # \u5b9a\u4e49\u6c60\u5316\u5c42&#xff0c;\u6c60\u5316\u6838\u7684\u5927\u5c0f kernel_size \u4e3a 2&#xff0c;\u6c60\u5316\u6b65\u957f\u4e3a 2<br \/>\n         self.max_pool1 &#061; MaxPool2D(kernel_size&#061;2, stride&#061;2)<br \/>\n         # \u5b9a\u4e49\u5377\u79ef\u5c42&#xff0c;\u8f93\u51fa\u7279\u5f81\u901a\u9053 out_channels \u8bbe\u7f6e\u4e3a 20&#xff0c;\u5377\u79ef\u6838\u7684\u5927\u5c0f kernel_size \u4e3a 5&#xff0c;\u5377\u79ef\u6b65\u957f stride&#061;1&#xff0c;padding&#061;2<br \/>\n         self.conv2 &#061; Conv2D(in_channels&#061;20, out_channels&#061;20, kernel_size&#061;5, stride&#061;1, padding&#061;2)<br \/>\n         # \u5b9a\u4e49\u6c60\u5316\u5c42&#xff0c;\u6c60\u5316\u6838\u7684\u5927\u5c0f kernel_size \u4e3a 2&#xff0c;\u6c60\u5316\u6b65\u957f\u4e3a 2<br \/>\n         self.max_pool2 &#061; MaxPool2D(kernel_size&#061;2, stride&#061;2)<br \/>\n         # \u5b9a\u4e49\u4e00\u5c42\u5168\u8fde\u63a5\u5c42&#xff0c;\u8f93\u51fa\u7ef4\u5ea6\u662f 10<br \/>\n         self.fc &#061; Linear(in_features&#061;980, out_features&#061;10)<\/p>\n<p>   # \u5b9a\u4e49\u7f51\u7edc\u524d\u5411\u8ba1\u7b97\u8fc7\u7a0b&#xff0c;\u5377\u79ef\u540e\u7d27\u63a5\u7740\u4f7f\u7528\u6c60\u5316\u5c42&#xff0c;\u6700\u540e\u4f7f\u7528\u5168\u8fde\u63a5\u5c42\u8ba1\u7b97\u6700\u7ec8\u8f93\u51fa<br \/>\n   # \u5377\u79ef\u5c42\u6fc0\u6d3b\u51fd\u6570\u4f7f\u7528 Relu&#xff0c;\u5168\u8fde\u63a5\u5c42\u6fc0\u6d3b\u51fd\u6570\u4f7f\u7528 softmax<br \/>\n     def forward(self, inputs):<br \/>\n         x &#061; self.conv1(inputs)<br \/>\n         x &#061; F.relu(x)<br \/>\n         x &#061; self.max_pool1(x)<br \/>\n         x &#061; self.conv2(x)<br \/>\n         x &#061; F.relu(x)<br \/>\n         x &#061; self.max_pool2(x)<br \/>\n         x &#061; paddle.reshape(x, [x.shape[0], -1])<br \/>\n         x &#061; self.fc(x)<br \/>\n         return x<\/p>\n<p>#\u521b\u5efa\u6a21\u578b<br \/>\nmodel &#061; MNIST()<\/p>\n<p>#\u8bbe\u7f6e\u4f18\u5316\u5668<br \/>\nopt &#061; paddle.optimizer.SGD(learning_rate&#061;0.001, parameters&#061;model.parameters())<br \/>\nEPOCH_NUM &#061; 10<br \/>\nfor epoch_id in range(EPOCH_NUM):<br \/>\n    model.train()<br \/>\n    for batch_id, data in enumerate(train_loader()):<br \/>\n        #\u51c6\u5907\u6570\u636e<br \/>\n        images, labels &#061; data<\/p>\n<p>        #\u524d\u5411\u8ba1\u7b97\u7684\u8fc7\u7a0b<br \/>\n        predicts &#061; model(images)<\/p>\n<p>        #\u8ba1\u7b97\u635f\u5931&#xff0c;\u53d6\u4e00\u4e2a\u6279\u6b21\u6837\u672c\u635f\u5931\u7684\u5e73\u5747\u503c<br \/>\n        loss &#061; F.cross_entropy(predicts, labels)<br \/>\n        avg_loss &#061; paddle.mean(loss)<\/p>\n<p>        #\u6bcf\u8bad\u7ec3\u4e86 100 \u6279\u6b21\u7684\u6570\u636e&#xff0c;\u6253\u5370\u4e0b\u5f53\u524d Loss \u7684\u60c5\u51b5<br \/>\n        if batch_id % 200 &#061;&#061; 0:<br \/>\n            print(&#034;epoch: {}, batch: {}, loss is: {}&#034;.format(epoch_id, batch_id, avg_loss.numpy()))<\/p>\n<p>        #\u540e\u5411\u4f20\u64ad&#xff0c;\u66f4\u65b0\u53c2\u6570\u7684\u8fc7\u7a0b<br \/>\n        avg_loss.backward()<br \/>\n        # \u6700\u5c0f\u5316 loss,\u66f4\u65b0\u53c2\u6570<br \/>\n        opt.step()<br \/>\n        # \u6e05\u9664\u68af\u5ea6<br \/>\n        opt.clear_grad()<\/p>\n<p>    # evaluate model after one epoch<br \/>\n    model.eval()<br \/>\n    accuracies &#061; []<br \/>\n    losses &#061; []<br \/>\n    for batch_id, data in enumerate(test_loader):<br \/>\n        #\u51c6\u5907\u6570\u636e<br \/>\n        images, labels &#061; data<br \/>\n        #\u524d\u5411\u8ba1\u7b97\u7684\u8fc7\u7a0b<br \/>\n        predicts &#061; model(images)<br \/>\n        #\u8ba1\u7b97\u635f\u5931<br \/>\n        loss &#061; F.cross_entropy(predicts, labels)<br \/>\n        #\u8ba1\u7b97\u51c6\u786e\u7387<br \/>\n        acc &#061; paddle.metric.accuracy(predicts, labels)<br \/>\n        accuracies.append(acc.numpy())<br \/>\n        losses.append(loss.numpy())<\/p>\n<p>    avg_acc, avg_loss &#061; np.mean(accuracies), np.mean(losses)<br \/>\n    print(&#034;[validation]After epoch {}: accuracy\/loss: {}\/{}&#034;.format(epoch_id, avg_acc, avg_loss))<\/p>\n<p>#\u4fdd\u5b58\u6a21\u578b\u53c2\u6570<br \/>\npaddle.save(model.state_dict(), &#039;mnist.pdparams&#039;)<\/p>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u4ee3\u7801&#xff0c;\u5b8c\u6210 MNIST \u6570\u636e\u96c6\u8f7d\u5165\u3001\u6784\u5efa\u4e86\u7b80\u5355\u7684\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u6a21\u578b\u3001\u4f7f\u7528 SGD \u4f18\u5316\u5668\u5728\u8bad\u7ec3\u6570\u636e\u4e0a\u4f18\u5316\u4e86 10 \u4e2a epoch \u7684\u6a21\u578b\u53c2\u6570&#xff0c;\u5e76\u4e14\u5c06\u8bad\u7ec3\u540e\u7684\u6a21\u578b\u53c2\u6570\u8fdb\u884c\u4e86\u4fdd\u5b58\u3002<\/p>\n<p>\u63a5\u4e0b\u6765&#xff0c;\u53ea\u9700\u8981\u5728\u524d\u9762\u4ee3\u7801\u7684\u5408\u9002\u4f4d\u7f6e\u6dfb\u52a0\u4e00\u4e9b VisualDL \u63a5\u53e3&#xff08;\u4e0b\u6587\u6709\u8be6\u7ec6\u89e3\u91ca\u5e76\u5728\u4ee3\u7801\u5757\u4e2d\u6ce8\u91ca\u63d0\u9192&#xff09;\u4ee5\u53ca\u7b80\u5355\u7684\u8bbe\u7f6e&#xff0c;\u5c31\u53ef\u4ee5\u5b9e\u73b0\u6a21\u578b\u7684 VisualDL \u53ef\u89c6\u5316\u5f00\u53d1\u3002<\/p>\n<p>VisualDL \u4ee5\u4e30\u5bcc\u7684\u56fe\u8868\u5448\u73b0\u8bad\u7ec3\u53c2\u6570\u53d8\u5316\u8d8b\u52bf\u3001\u6a21\u578b\u7ed3\u6784\u3001\u6570\u636e\u6837\u672c\u3001\u9ad8\u7ef4\u6570\u636e\u5206\u5e03\u7b49&#xff0c;\u53ef\u4ee5\u5e2e\u52a9\u7528\u6237\u66f4\u6e05\u6670\u76f4\u89c2\u5730\u7406\u89e3\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u8bad\u7ec3\u8fc7\u7a0b\u53ca\u6a21\u578b\u7ed3\u6784&#xff0c;\u8fdb\u800c\u5b9e\u73b0\u9ad8\u6548\u7684\u6a21\u578b\u4f18\u5316\u3002<\/p>\n<p>\u6dfb\u52a0 VisualDL \u63a5\u53e3\u540e\u7684\u5b8c\u6574\u4ee3\u7801&#xff0c;\u53ef\u70b9\u51fb\u94fe\u63a5\u5728\u7ebf\u8fd0\u884c\u3002\u4ee3\u7801\u8fd0\u884c\u5b8c\u6210\u540e&#xff0c;\u70b9\u51fb\u5de6\u4fa7\u7684\u53ef\u89c6\u5316\u56fe\u6807&#x1f4c8;\u5373\u53ef\u67e5\u770b\u53ef\u89c6\u5316\u56fe\u50cf\u3002<\/p>\n<p>\u63a5\u4e0b\u6765&#xff0c;\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 VisualDL \u8fdb\u884c\u6a21\u578b\u5f00\u53d1\u53ef\u89c6\u5316\u3002<\/p>\n<h3>\u4e00\u3001\u73af\u5883\u51c6\u5907<\/h3>\n<h4>1.1 \u5b89\u88c5 VisualDL<\/h4>\n<p>\u5982\u679c\u8fd8\u6ca1\u6709\u5b89\u88c5 visualdl&#xff0c;\u53ef\u4ee5\u4f7f\u7528 pip \u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<p>pip install visualdl<\/p>\n<p>\u5b89\u88c5\u5b8c\u6210\u540e&#xff0c;\u6253\u5f00\u547d\u4ee4\u884c&#xff0c;\u5982\u679c\u53ef\u4ee5\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u4ee3\u8868\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<p>visualdl &#8211;version<\/p>\n<h4>1.2 \u8bbe\u7f6e VisualDL<\/h4>\n<p>VisualDL \u901a\u5e38\u5206\u4e3a\u201c\u5199\u201d\u548c\u201c\u8bfb\u201d\u4e24\u90e8\u5206&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u201c\u5199\u201d\u6570\u636e&#xff1a;\u901a\u8fc7\u5728\u8bad\u7ec3\u7a0b\u5e8f\u4e2d\u52a0\u5165\u4ee3\u7801&#xff0c;\u5c06\u6240\u8981\u76d1\u63a7\u7684\u6570\u636e\u8bb0\u5f55\u5230\u65e5\u5fd7\u6587\u4ef6&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u201c\u8bfb\u201d\u6570\u636e&#xff1a;\u542f\u52a8 VisualDL \u7684\u670d\u52a1\u3001\u89e3\u6790\u65e5\u5fd7\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u3001\u5e76\u5728\u6d4f\u89c8\u5668\u4e2d\u4ee5\u56fe\u8868\u7684\u5f62\u5f0f\u5448\u73b0&#xff0c;\u4ece\u800c\u5b9e\u73b0\u53ef\u89c6\u5316\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u4f7f\u7528 VisualDL \u5199\u6570\u636e&#xff0c;\u9700\u8981\u5148\u5bfc\u5165 visualdl \u5e93\u7684 LogWriter \u7c7b\u3002\u6240\u6709\u5199\u5165\u6570\u636e\u7684\u64cd\u4f5c\u90fd\u5c06\u57fa\u4e8e LogWriter \u7684\u5bf9\u8c61\u8fdb\u884c\u3002<\/p>\n<p>\u53ef\u4ee5\u6309\u7167\u4e0b\u5217\u65b9\u5f0f\u5728\u6587\u4ef6\u5934\u90e8\u5bfc\u5165 visualdl \u5e93&#xff0c;\u5e76\u4f7f\u7528 LogWriter \u7c7b\u3002<\/p>\n<p>import os<br \/>\nimport random<\/p>\n<p>import numpy as np<br \/>\n# \u52a0\u8f7d\u98de\u6868\u76f8\u5173\u5e93<br \/>\nimport paddle<br \/>\nfrom paddle.nn import Conv2D, MaxPool2D, Linear<br \/>\nimport paddle.nn.functional as F<\/p>\n<p># \u4ece visualdl \u5e93\u4e2d\u5f15\u5165 LogWriter \u7c7b<br \/>\nfrom visualdl import LogWriter<br \/>\n# \u521b\u5efa LogWriter \u5bf9\u8c61&#xff0c;\u6307\u5b9a logdir \u53c2\u6570&#xff0c;\u5982\u679c\u6307\u5b9a\u8def\u5f84\u4e0d\u5b58\u5728\u5c06\u4f1a\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6\u5939<br \/>\nlogwriter &#061; LogWriter(logdir&#061;&#039;.\/runs\/mnist_experiment&#039;)<\/p>\n<p>\u8fd0\u884c\u8be5\u4ee3\u7801\u540e&#xff0c;\u5c06\u4f1a\u521b\u5efa\u4e00\u4e2a.\/runs\/mnist_experiment \u6587\u4ef6\u5939&#xff0c;\u7528\u4e8e\u5b58\u50a8\u5199\u5165\u5230 VisualDL \u7684\u6570\u636e\u3002<\/p>\n<p>\u53ef\u4ee5\u5728\u8bad\u7ec3\u7a0b\u5e8f\u6267\u884c\u524d\u3001\u4e2d\u3001\u540e\u4efb\u610f\u4e00\u4e2a\u9636\u6bb5&#xff0c;\u542f\u52a8 VisualDL \u7684\u53ef\u89c6\u5316\u670d\u52a1\u3001\u8bfb\u53d6\u6570\u636e\u3001\u5e76\u8fdb\u5165\u6d4f\u89c8\u5668\u67e5\u770b\u3002\u542f\u52a8\u547d\u4ee4\u4e3a&#xff1a;<\/p>\n<p>visualdl &#8211;logdir .\/runs\/mnist_experiment &#8211;model .\/runs\/mnist_experiment\/model.pdmodel &#8211;host 0.0.0.0 &#8211;port 8040<\/p>\n<p>&#8211;logdir&#xff1a;\u4e0e\u4f7f\u7528 LogWriter \u65f6\u6307\u5b9a\u7684\u53c2\u6570\u76f8\u540c\u3002<\/p>\n<p>&#8211;model&#xff1a;&#xff08;\u53ef\u9009&#xff09;\u4e3a\u4fdd\u5b58\u7684\u7f51\u7edc\u6a21\u578b\u7ed3\u6784\u6587\u4ef6\u3002<\/p>\n<p>&#8211;host&#xff1a;\u6307\u5b9a\u670d\u52a1\u7684 IP \u5730\u5740\u3002<\/p>\n<p>&#8211;port&#xff1a;\u6307\u5b9a\u670d\u52a1\u7684\u7aef\u53e3\u5730\u5740\u3002<\/p>\n<p>\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4e0a\u8ff0\u547d\u4ee4\u542f\u52a8\u670d\u52a1\u540e&#xff0c;\u53ef\u4ee5\u5728\u6d4f\u89c8\u5668\u4e2d\u8f93\u5165\u00a0http:\/\/localhost:8040\u00a0(\u4e5f\u53ef\u4ee5\u67e5\u770b ip \u5730\u5740&#xff0c;\u5c06 localhost \u6362\u6210 ip)\u8fdb\u884c\u67e5\u770b\u3002<\/p>\n<p>\u5982\u679c\u662f\u5728AI Studio\u4e0a\u8bad\u7ec3\u7a0b\u5e8f&#xff0c;\u53ef\u4ee5\u5728\u6a21\u578b\u8bad\u7ec3\u7ed3\u675f\u540e&#xff0c;\u53c2\u8003\u5982\u4e0b\u754c\u9762\u8bbe\u7f6e\u65e5\u5fd7\u6587\u4ef6\u6240\u5728\u76ee\u5f55\u548c\u6a21\u578b\u6587\u4ef6&#xff0c;\u542f\u52a8 VisualDL \u7684\u53ef\u89c6\u5316\u670d\u52a1\u3002<\/p>\n<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"img\" height=\"960\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/03\/20260303012544-69a638981bc5b.png\" width=\"1920\" \/><\/p>\n<h3>\u4e8c\u3001\u5199\u5165\u6570\u636e\u5e76\u53ef\u89c6\u5316<\/h3>\n<p>\u521b\u5efa\u4e86 LogWriter \u5bf9\u8c61\u4e4b\u540e&#xff0c;\u5c31\u53ef\u4ee5\u5199\u5165\u60f3\u8981\u89c2\u5bdf\u7684\u6570\u636e\u4e86\u3002\u9700\u8981\u76d1\u63a7\u7684\u6570\u636e\u901a\u5e38\u5305\u542b\u4ee5\u4e0b\u51e0\u7c7b&#xff1a;<\/p>\n<p>\u67e5\u770b\u8bad\u7ec3\u6570\u636e\u3001\u67e5\u770b\u7f51\u7edc\u6a21\u578b\u7ed3\u6784\u3001\u67e5\u770b\u8bad\u7ec3\u8fc7\u7a0b\u7f51\u7edc\u4e2d\u6a21\u578b\u53c2\u6570\u7684\u53d8\u5316\u3001\u67e5\u770b\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u635f\u5931\u51fd\u6570\u503c\u7684\u53d8\u5316&#xff0c;\u4ee5\u53ca\u6d4b\u8bd5\u96c6\u4e0a\u635f\u5931\u51fd\u6570\u503c\u548c\u51c6\u786e\u7387\u7684\u53d8\u5316\u3002<\/p>\n<p>\u4e0b\u9762\u4f9d\u6b21\u8bf4\u660e\u5982\u4f55\u6dfb\u52a0\u5bf9\u8fd9\u4e9b\u6570\u636e\u7684\u76d1\u63a7\u3002<\/p>\n<h4>2.1 \u68c0\u67e5\u8bad\u7ec3\u6570\u636e<\/h4>\n<h5>2.1.1 \u67e5\u770b\u8f93\u5165\u56fe\u50cf<\/h5>\n<p>\u5982\u679c\u60f3\u77e5\u9053\u8bad\u7ec3\u6216\u6d4b\u8bd5\u6570\u636e\u96c6\u4e2d\u7684\u8f93\u5165\u56fe\u50cf\u662f\u4ec0\u4e48\u6837\u7684&#xff0c;\u53ef\u4ee5\u6309\u5982\u4e0b\u65b9\u5f0f\u4f7f\u7528add_image_matrix\u63a5\u53e3\u5c06\u8f93\u5165\u56fe\u50cf\u5217\u8868\u5199\u5165 VisualDL&#xff0c;VisualDL \u4f1a\u81ea\u52a8\u5c06\u56fe\u50cf\u6392\u5217\u6210\u7f51\u683c\u8fdb\u884c\u5c55\u793a\u3002<\/p>\n<p># \u6570\u636e\u8f7d\u5165<br \/>\nclass MNISTDataset():<br \/>\n  def __init__(self, mode&#061;&#039;train&#039;):<br \/>\n    self.mnist_data &#061; paddle.vision.datasets.MNIST(mode&#061;mode)<\/p>\n<p>  def __getitem__(self, idx):<br \/>\n    data, label &#061; self.mnist_data[idx]<br \/>\n    data &#061; np.reshape(data, [1, 28, 28]).astype(&#039;float32&#039;) \/ 255<br \/>\n    label &#061; np.reshape(label, [1]).astype(&#039;int64&#039;)<br \/>\n    return (data, label)<\/p>\n<p>  def __len__(self):<br \/>\n    return len(self.mnist_data)<\/p>\n<p># \u67e5\u770b 9 \u5f20\u8f93\u5165\u7684\u8bad\u7ec3\u56fe\u50cf\u7684\u6837\u4f8b<br \/>\ndataset &#061; MNISTDataset(mode&#061;&#039;train&#039;)<br \/>\nimage_matrix &#061; []<br \/>\nfor i in range(9):<br \/>\n  image, label &#061; dataset[i]<br \/>\n  # \u5c06 dataset \u4e2d\u7684 CHW \u6392\u5217\u7684\u56fe\u50cf\u8f6c\u6362\u6210 HWC \u6392\u5217\u518d\u5199\u5165 VisualDL<br \/>\n  image_matrix.append(image.transpose([1,2,0]))<br \/>\n# \u5c06\u4e5d\u5f20\u8f93\u5165\u56fe\u50cf\u5408\u6210\u957f\u5bbd\u76f8\u540c\u7684\u56fe\u50cf\u7f51\u683c&#xff0c;\u5373 3X3 \u7684\u56fe\u50cf\u7f51\u683c<br \/>\nlogwriter.add_image_matrix(tag&#061;&#039;input_images&#039;, step&#061;1, imgs&#061;image_matrix, rows&#061;-1)<\/p>\n<p>\u201c\u6837\u672c\u6570\u636e\u00b7\u56fe\u50cf\u201d\u9875\u9762\u663e\u793a\u4e86\u901a\u8fc7 add_image_matrix \u63a5\u53e3\u5199\u5165\u7684\u56fe\u50cf\u5217\u8868&#xff0c;\u53ef\u4ee5\u770b\u5230\u5199\u5165\u7684 9 \u5f20\u56fe\u50cf\u6309\u7167 3*3 \u7684\u6392\u5217\u65b9\u5f0f\u5c55\u793a\u4e86\u51fa\u6765&#xff0c;\u7528\u4e8e\u8bad\u7ec3\u7684\u6570\u636e\u662f\u624b\u5199\u5b57\u4f53\u7684\u6570\u5b57\u3002<\/p>\n<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"img\" height=\"880\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/03\/20260303012545-69a638992c603.png\" width=\"1920\" \/><\/p>\n<p>\u56fe 1&#xff1a;\u67e5\u770b\u8f93\u5165\u56fe\u50cf<\/p>\n<p>\u8fd8\u53ef\u4ee5\u8fdb\u4e00\u6b65\u67e5\u770b\u8f93\u5165\u6570\u636e\u6620\u5c04\u5230\u4f4e\u7ef4\u7a7a\u95f4\u65f6\u7684\u5173\u7cfb\u3002\u4f7f\u7528add_embeddings\u63a5\u53e3\u5c06\u8f93\u5165\u56fe\u50cf\u5217\u8868\u5199\u5165 VisualDL\u3002<\/p>\n<p># \u5c06\u4e5d\u5f20\u8f93\u5165\u56fe\u50cf\u4ee5\u5411\u91cf\u7684\u5f62\u5f0f\u5199\u5165 embeddings&#xff0c;\u67e5\u770b\u6570\u636e\u964d\u7ef4\u540e\u7684\u5173\u7cfb<br \/>\ntags &#061; [&#039;image_{}&#039;.format(i) for i in range(9)]<br \/>\nlogwriter.add_embeddings(&#039;input_image_embeddings&#039;, mat&#061;[img.reshape(-1) for img in image_matrix], metadata&#061;tags)<\/p>\n<p>\u201c\u6570\u636e\u964d\u7ef4\u201d\u9875\u9762\u663e\u793a\u4e86\u901a\u8fc7 add_embeddings \u63a5\u53e3\u5199\u5165\u7684\u5411\u91cf\u964d\u7ef4\u540e\u7684\u4f4d\u7f6e\u5173\u7cfb\u3002\u4e00\u822c\u6765\u8bf4&#xff0c;\u8d8a\u76f8\u4f3c\u7684\u56fe\u50cf\u6295\u5c04\u5230\u4f4e\u7ef4\u7a7a\u95f4\u7684\u8ddd\u79bb\u5c31\u4f1a\u8d8a\u76f8\u8fd1\u3002<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"img\" height=\"299\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/03\/20260303012545-69a63899c0dfd.jpg\" width=\"534\" \/><\/p>\n<p>\u56fe 2&#xff1a;\u67e5\u770b\u6570\u636e\u964d\u7ef4\u7684\u7ed3\u679c<\/p>\n<h5>2.1.2 \u67e5\u770b\u7f51\u7edc\u7ed3\u6784<\/h5>\n<p>\u5982\u679c\u662f\u901a\u8fc7\u98de\u6868\u7ec4\u5efa\u7684\u7f51\u7edc\u7ed3\u6784&#xff0c;\u53ef\u4ee5\u4f7f\u7528paddle.jit.save\u63a5\u53e3\u5c06\u7f51\u7edc\u7ed3\u6784\u4fdd\u5b58\u4e0b\u6765&#xff0c;\u7136\u540e\u4f7f\u7528 VisualDL \u8fdb\u884c\u67e5\u770b\u3002<\/p>\n<p>#\u521b\u5efa\u6a21\u578b<br \/>\nmodel &#061; MNIST()<br \/>\n#\u4fdd\u5b58\u6a21\u578b&#xff0c;\u83b7\u53d6\u6a21\u578b\u7ed3\u6784\u6587\u4ef6<br \/>\npaddle.jit.save(model, &#039;.\/runs\/mnist_experiment\/model&#039;, [paddle.static.InputSpec([-1,1,28,28])])<\/p>\n<p>\u8be5\u4ee3\u7801\u4f1a\u5728.\/runs\/mnist_experiment\/\u76ee\u5f55\u4e0b\u751f\u6210\u6a21\u578b\u7ed3\u6784\u6587\u4ef6 model.pdmodel\u3002<\/p>\n<p>\u201c\u7f51\u7edc\u7ed3\u6784\u201d\u9875\u9762\u663e\u793a\u4e86\u4f7f\u7528\u98de\u6868\u642d\u5efa\u7684\u7f51\u7edc\u7ed3\u6784\u3002\u53ef\u4ee5\u6e05\u6670\u7684\u770b\u5230\u5176\u62d3\u6251\u8fde\u63a5\u65b9\u5f0f\u4ee5\u53ca\u6bcf\u4e2a\u7ed3\u6784\u5355\u5143\u7684\u8be6\u7ec6\u4fe1\u606f\u3002\u901a\u8fc7\u7f51\u7edc\u7ed3\u6784\u56fe&#xff0c;\u53ef\u4ee5\u5206\u6790\u81ea\u5df1\u642d\u5efa\u7684\u7f51\u7edc\u62d3\u6251\u662f\u5426\u7b26\u5408\u8bbe\u8ba1\u65f6\u7684\u9884\u671f&#xff0c;\u8f85\u52a9\u505a\u7f51\u7edc\u642d\u5efa\u7684\u8c03\u8bd5&#xff1b;\u4ee5\u53ca\u67e5\u770b\u6bcf\u4e2a\u8282\u70b9\u8f93\u51fa\u7684\u53d8\u91cf\u7684\u5f62\u72b6&#xff0c;\u5e76\u901a\u8fc7\u6b64\u5f62\u72b6\u8bc4\u4f30\u53c2\u6570\u91cf\u7684\u5927\u5c0f\u3002<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"img\" height=\"299\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/03\/20260303012546-69a6389a008be.jpg\" width=\"534\" \/><\/p>\n<p>\u56fe 3&#xff1a;\u67e5\u770b\u7f51\u7edc\u7ed3\u6784<\/p>\n<h5>2.1.3 \u8bb0\u5f55\u8bad\u7ec3\u65f6\u7684\u8d85\u53c2\u6570\u914d\u7f6e<\/h5>\n<p>\u901a\u8fc7add_hparams\u63a5\u53e3\u8bb0\u5f55\u4e0b\u5f53\u524d\u5b9e\u9a8c\u7684\u8d85\u53c2\u6570\u914d\u7f6e\u4fe1\u606f&#xff0c;\u6bd4\u5982\u5b66\u4e60\u7387 lr\u3001batch\u3001\u6240\u7528\u7684\u4f18\u5316\u5668\u7b49\u4fe1\u606f&#xff0c;\u5e76\u4e14\u5173\u8054\u8be5\u8d85\u53c2\u6570\u914d\u7f6e\u4e0b\u8bb0\u5f55\u8fc7\u7684\u66f2\u7ebf\u7684\u540d\u79f0&#xff0c;\u65b9\u4fbf\u8fdb\u884c\u591a\u4e2a\u4e0d\u540c\u8d85\u53c2\u6570\u8bbe\u5b9a\u4e0b\u5b9e\u9a8c\u7684\u5bf9\u6bd4\u3002<\/p>\n<p>\u6bd4\u5982\u7b2c\u4e00\u6b21\u5b9e\u9a8c\u8bbe\u7f6e\u5b66\u4e60\u7387\u4e3a 1e-3&#xff0c;\u5e76\u4f7f\u7528 sgd \u4f18\u5316\u5668&#xff0c;\u8bb0\u5f55\u76f8\u5173\u8d85\u53c2\u6570\u7684\u914d\u7f6e\u60c5\u51b5\u3002<\/p>\n<p>logwriter.add_hparams(hparams_dict&#061;{&#039;lr&#039;: 0.001, &#039;batch_size&#039;: 16, &#039;opt&#039;: &#039;sgd&#039;},<br \/>\n                           metrics_list&#061;[&#039;train_avg_loss&#039;, &#039;test_avg_loss&#039;, &#039;test_avg_acc&#039;])<\/p>\n<p>\u4e3a\u4e86\u6bd4\u8f83\u4e0d\u540c\u8d85\u53c2\u6570\u8bbe\u7f6e\u5bf9\u5b9e\u9a8c\u7684\u5f71\u54cd&#xff0c;\u8fdb\u884c\u7b2c\u4e8c\u6b21\u5b9e\u9a8c&#xff0c;\u5e76\u8bbe\u7f6e\u5b66\u4e60\u7387\u4e3a 1e-4&#xff0c;\u9009\u7528 adam \u4f5c\u4e3a\u4f18\u5316\u5668\u3002<\/p>\n<p>logwriter.add_hparams(hparams_dict&#061;{&#039;lr&#039;: 0.0001, &#039;batch_size&#039;: 16, &#039;opt&#039;: &#039;adam&#039;},<br \/>\n                           metrics_list&#061;[&#039;train_avg_loss&#039;, &#039;test_avg_loss&#039;, &#039;test_avg_acc&#039;])<\/p>\n<p>\u201c\u8d85\u53c2\u53ef\u89c6\u5316\u201d\u9875\u9762\u4f1a\u663e\u793a\u901a\u8fc7 add_hparams \u63a5\u53e3\u8bb0\u5f55\u8fd9\u4e24\u6b21\u4e0d\u540c\u5b9e\u9a8c\u7684\u8d85\u53c2\u6570\u4fe1\u606f&#xff0c;\u5e76\u5bf9\u5173\u8054\u7684\u66f2\u7ebf\u8fdb\u884c\u5bf9\u6bd4\u3002\u901a\u8fc7\u8868\u683c\u89c6\u56fe&#xff0c;\u5e73\u884c\u5750\u6807\u56fe\u548c\u6563\u70b9\u56fe\u4e09\u79cd\u56fe&#xff0c;\u53ef\u4ee5\u53d1\u73b0\u5728\u5b66\u4e60\u7387\u4e3a 1e-4&#xff0c;\u4f18\u5316\u5668\u4e3a adam \u7684\u65f6\u5019&#xff0c;\u8bad\u7ec3\u7684\u5e73\u5747\u635f\u5931\u503c\u66f4\u4f4e&#xff0c;\u6d4b\u8bd5\u96c6\u4e0a\u7684\u6d4b\u8bd5\u7cbe\u5ea6\u66f4\u9ad8\u3002<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"img\" height=\"299\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/03\/20260303012546-69a6389a3532f.jpg\" width=\"534\" \/><\/p>\n<p>\u56fe 4&#xff1a;\u8d85\u53c2\u5b9e\u9a8c\u5bf9\u6bd4-\u8868\u683c\u89c6\u56fe<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"img\" height=\"299\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/03\/20260303012546-69a6389a75474.jpg\" width=\"534\" \/><\/p>\n<p>\u56fe 5&#xff1a;\u8d85\u53c2\u5b9e\u9a8c\u5bf9\u6bd4-\u5e73\u884c\u5750\u6807\u56fe<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"img\" height=\"299\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/03\/20260303012546-69a6389ab0e70.jpg\" width=\"534\" \/><\/p>\n<p>\u56fe 6&#xff1a;\u8d85\u53c2\u5b9e\u9a8c\u5bf9\u6bd4-\u6563\u70b9\u56fe<\/p>\n<p>\u56de\u5230\u201c\u6807\u91cf\u6570\u636e\u201d\u9875\u9762&#xff0c;\u67e5\u770b test_avg_acc \u66f2\u7ebf\u3002\u540c\u6837\u53ef\u4ee5\u53d1\u73b0&#xff0c;\u5b66\u4e60\u7387\u4e3a 1e-4\u3001\u4f18\u5316\u5668\u4e3a adam \u7684\u6d4b\u8bd5\u51c6\u786e\u7387\u66f2\u7ebf&#xff0c;\u5728\u5b66\u4e60\u7387\u4e3a 1e-3\u3001\u4f18\u5316\u5668\u4e3a sgd \u5bf9\u5e94\u7684\u66f2\u7ebf\u4e4b\u4e0a\u3002\u901a\u8fc7\u6b64\u5bf9\u6bd4&#xff0c;\u53ef\u4ee5\u76f4\u89c2\u4e86\u89e3\u8d85\u53c2\u5b9e\u9a8c\u7ed3\u679c\u3002<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"img\" height=\"299\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/03\/20260303012546-69a6389aec8fb.jpg\" width=\"534\" \/><\/p>\n<p>\u56fe 7&#xff1a;\u67e5\u770b\u6d4b\u8bd5\u51c6\u786e\u7387\u66f2\u7ebf<\/p>\n<h4>2.2 \u8ddf\u8e2a\u6a21\u578b\u8bad\u7ec3<\/h4>\n<h5>2.2.1 \u67e5\u770b\u7f51\u7edc\u6a21\u578b\u53c2\u6570\u53d8\u5316<\/h5>\n<p>\u5728\u7f51\u7edc\u6a21\u578b\u8bad\u7ec3\u7684\u8fc7\u7a0b\u4e2d&#xff0c;\u6a21\u578b\u7684\u53c2\u6570\u4f1a\u968f\u7740\u4f18\u5316\u7b97\u6cd5\u7684\u66f4\u65b0\u800c\u4e0d\u65ad\u53d8\u5316\u3002\u901a\u8fc7\u5c06\u6a21\u578b\u53c2\u6570\u5199\u5165 VisualDL&#xff0c;\u53ef\u4ee5\u4e86\u89e3\u6a21\u578b\u53c2\u6570\u7684\u503c\u7684\u5206\u5e03\u662f\u5982\u4f55\u968f\u7740\u8bad\u7ec3\u8fc7\u7a0b\u800c\u53d1\u751f\u6539\u53d8\u7684\u3002\u4f7f\u7528add_histogram\u63a5\u53e3\u53ef\u4ee5\u5199\u5165\u6a21\u578b\u53c2\u6570\u3002<\/p>\n<p>  for epoch_id in range(EPOCH_NUM):<br \/>\n      model.train()<br \/>\n      train_batchs_per_epoch &#061; len(train_loader)<br \/>\n      for batch_id, data in enumerate(train_loader):<br \/>\n          #\u51c6\u5907\u6570\u636e<br \/>\n          images, labels &#061; data<\/p>\n<p>          #\u524d\u5411\u8ba1\u7b97\u7684\u8fc7\u7a0b<br \/>\n          predicts &#061; model(images)<\/p>\n<p>          #\u8ba1\u7b97\u635f\u5931&#xff0c;\u53d6\u4e00\u4e2a\u6279\u6b21\u6837\u672c\u635f\u5931\u7684\u5e73\u5747\u503c<br \/>\n          loss &#061; F.cross_entropy(predicts, labels)<br \/>\n          avg_loss &#061; paddle.mean(loss)<\/p>\n<p>          #\u8bb0\u5f55\u5f53\u524d\u8bad\u7ec3 Loss \u5230 VisualDL<br \/>\n          logwriter.add_scalar(&#034;train_avg_loss&#034;, value&#061;avg_loss.numpy(), step&#061;batch_id&#043;epoch_id*(train_batchs_per_epoch))<\/p>\n<p>          #\u8bb0\u5f55\u7f51\u7edc\u4e2d\u6700\u540e\u4e00\u4e2a fc \u5c42\u7684\u53c2\u6570\u5230 VisualDL<br \/>\n          logwriter.add_histogram(&#034;fc_weight&#034;, values&#061;model.fc.weight.numpy(), step&#061;batch_id&#043;epoch_id*(train_batchs_per_epoch))<\/p>\n<p>          #\u6bcf\u8bad\u7ec3\u4e86 100 \u6279\u6b21\u7684\u6570\u636e&#xff0c;\u6253\u5370\u4e0b\u5f53\u524d Loss \u7684\u60c5\u51b5<br \/>\n          if batch_id % 200 &#061;&#061; 0:<br \/>\n              print(&#034;epoch: {}, batch: {}, loss is: {}&#034;.format(epoch_id, batch_id, avg_loss.numpy()))<\/p>\n<p>          #\u540e\u5411\u4f20\u64ad&#xff0c;\u66f4\u65b0\u53c2\u6570\u7684\u8fc7\u7a0b<br \/>\n          avg_loss.backward()<br \/>\n          # \u6700\u5c0f\u5316 loss,\u66f4\u65b0\u53c2\u6570<br \/>\n          opt.step()<br \/>\n          # \u6e05\u9664\u68af\u5ea6<br \/>\n          opt.clear_grad()<\/p>\n<p>\u201c\u76f4\u65b9\u56fe\u201d\u9875\u9762\u663e\u793a\u4e86 add_histogram \u63a5\u53e3\u5199\u5165\u7684\u6a21\u578b\u53c2\u6570\u3002\u76f4\u65b9\u56fe\u7684\u6a2a\u5750\u6807\u662f\u503c\u7684\u5927\u5c0f&#xff0c;\u7eb5\u5750\u6807\u662f step&#xff0c;\u9ad8\u5ea6\u4ee3\u8868\u503c\u5bf9\u5e94\u7684\u5143\u7d20\u6570\u91cf\u3002\u4e00\u822c\u6b63\u5e38\u8bad\u7ec3\u8fc7\u7a0b\u7684\u53c2\u6570\u5206\u5e03\u53d8\u5316&#xff0c;\u5373\u5411\u4e0b\u56fe\u4e00\u6837&#xff0c;\u7531\u8f83\u5927\u7684\u65b9\u5dee\u5411\u8f83\u5c0f\u65b9\u5dee\u53d8\u5316&#xff0c;\u4ece\u7c7b\u4f3c\u5747\u5300\u5206\u5e03\u504f\u5411\u7c7b\u4f3c\u9ad8\u65af\u5206\u5e03\u3002<\/p>\n<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"img\" height=\"884\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/03\/20260303012547-69a6389b3c8a8.png\" width=\"1920\" \/><\/p>\n<p>\u56fe 8&#xff1a;\u67e5\u770b\u7f51\u7edc\u6a21\u578b\u53c2\u6570\u53d8\u5316<\/p>\n<h5>2.2.2 \u67e5\u770b\u8bad\u7ec3\u8fc7\u7a0b\u635f\u5931\u51fd\u6570\u503c\u53d8\u5316<\/h5>\n<p>\u7f51\u7edc\u6a21\u578b\u7684\u8bad\u7ec3\u5373\u662f\u76ee\u6807\u635f\u5931\u51fd\u6570\u7684\u4f18\u5316\u8fc7\u7a0b\u3002\u901a\u5e38\u635f\u5931\u51fd\u6570\u7684\u503c\u4f1a\u968f\u7740\u4f18\u5316\u7b97\u6cd5\u7684\u8fed\u4ee3\u4e0d\u65ad\u53d8\u5c0f&#xff0c;\u4f46\u662f\u4e5f\u53ef\u80fd\u4f1a\u56e0\u4e3a\u68af\u5ea6\u7206\u70b8\u6216\u8005\u4e0d\u6536\u655b\u7b49\u539f\u56e0\u5e76\u6ca1\u6709\u8fbe\u5230\u9884\u671f\u7684\u6548\u679c&#xff0c;\u53ef\u4ee5\u901a\u8fc7add_scalar\u63a5\u53e3\u5c06\u8bad\u7ec3\u8fc7\u7a0b\u7684\u635f\u5931\u51fd\u6570\u7684\u503c\u8bb0\u5f55\u4e0b\u6765\u89c2\u5bdf\u53d8\u5316\u3002<\/p>\n<p>for epoch_id in range(EPOCH_NUM):<br \/>\n      model.train()<br \/>\n      train_batchs_per_epoch &#061; len(train_loader)<br \/>\n      for batch_id, data in enumerate(train_loader):<br \/>\n          #\u51c6\u5907\u6570\u636e<br \/>\n          images, labels &#061; data<\/p>\n<p>          #\u524d\u5411\u8ba1\u7b97\u7684\u8fc7\u7a0b<br \/>\n          predicts &#061; model(images)<\/p>\n<p>          #\u8ba1\u7b97\u635f\u5931&#xff0c;\u53d6\u4e00\u4e2a\u6279\u6b21\u6837\u672c\u635f\u5931\u7684\u5e73\u5747\u503c<br \/>\n          loss &#061; F.cross_entropy(predicts, labels)<br \/>\n          avg_loss &#061; paddle.mean(loss)<\/p>\n<p>          #\u8bb0\u5f55\u5f53\u524d\u8bad\u7ec3 Loss \u5230 VisualDL<br \/>\n          logwriter.add_scalar(&#034;train_avg_loss&#034;, value&#061;avg_loss.numpy(), step&#061;batch_id&#043;epoch_id*(train_batchs_per_epoch))<\/p>\n<p>          #\u8bb0\u5f55\u7f51\u7edc\u4e2d\u6700\u540e\u4e00\u4e2a fc \u5c42\u7684\u53c2\u6570\u5230 VisualDL<br \/>\n          logwriter.add_histogram(&#034;fc_weight&#034;, values&#061;model.fc.weight.numpy(), step&#061;batch_id&#043;epoch_id*(train_batchs_per_epoch))<\/p>\n<p>          #\u6bcf\u8bad\u7ec3\u4e86 100 \u6279\u6b21\u7684\u6570\u636e&#xff0c;\u6253\u5370\u4e0b\u5f53\u524d Loss \u7684\u60c5\u51b5<br \/>\n          if batch_id % 200 &#061;&#061; 0:<br \/>\n              print(&#034;epoch: {}, batch: {}, loss is: {}&#034;.format(epoch_id, batch_id, avg_loss.numpy()))<\/p>\n<p>          #\u540e\u5411\u4f20\u64ad&#xff0c;\u66f4\u65b0\u53c2\u6570\u7684\u8fc7\u7a0b<br \/>\n          avg_loss.backward()<br \/>\n          # \u6700\u5c0f\u5316 loss,\u66f4\u65b0\u53c2\u6570<br \/>\n          opt.step()<br \/>\n          # \u6e05\u9664\u68af\u5ea6<br \/>\n          opt.clear_grad()<\/p>\n<p>\u201c\u6807\u91cf\u6570\u636e\u201d\u9875\u9762\u663e\u793a\u4e86 add_scalar \u63a5\u53e3\u5199\u5165\u7684\u6bcf\u4e2a step \u7684\u635f\u5931\u51fd\u6570\u503c\u3002\u53ef\u4ee5\u770b\u5230\u968f\u7740\u7f51\u7edc\u7684\u8bad\u7ec3&#xff0c;\u635f\u5931\u51fd\u6570\u7684\u503c\u8d8b\u52bf\u662f\u5148\u5feb\u901f\u4e0b\u964d&#xff0c;\u7136\u540e\u7f13\u6162\u4e0b\u964d\u5e76\u8d8b\u4e8e\u7a33\u5b9a&#xff0c;\u8bf4\u660e\u6a21\u578b\u7684\u8bad\u7ec3\u8fc7\u7a0b\u6b63\u5e38\u5e76\u4e14\u6700\u540e\u6536\u655b\u4e86\u3002<\/p>\n<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"img\" height=\"880\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/03\/20260303012547-69a6389bed513.png\" width=\"1920\" \/><\/p>\n<p>\u56fe 9&#xff1a;\u67e5\u770b\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u635f\u5931\u51fd\u6570\u503c\u53d8\u5316<\/p>\n<h4>2.3 \u8bc4\u4f30\u6a21\u578b\u8bad\u7ec3\u6548\u679c<\/h4>\n<h5>2.3.1 \u67e5\u770b\u6d4b\u8bd5\u96c6\u7684\u635f\u5931\u51fd\u6570\u503c\u548c\u51c6\u786e\u7387<\/h5>\n<p>\u7f51\u7edc\u6a21\u578b\u8bad\u7ec3\u5b8c\u6210\u540e&#xff0c;\u9700\u8981\u5728\u6d4b\u8bd5\u96c6\u4e0a\u9a8c\u8bc1\u5176\u6548\u679c\u3002\u53ef\u4ee5\u4f7f\u7528 add_scalar \u63a5\u53e3\u8bb0\u5f55\u6d4b\u8bd5\u96c6\u4e0a\u635f\u5931\u51fd\u6570\u503c\u548c\u51c6\u786e\u7387\u662f\u5982\u4f55\u968f\u7740\u8bad\u7ec3\u8fed\u4ee3\u7684\u6df1\u5165\u800c\u53d1\u751f\u53d8\u5316\u7684\u3002<\/p>\n<p>for batch_id, data in enumerate(test_loader):<br \/>\n      #\u51c6\u5907\u6570\u636e<br \/>\n      images, labels &#061; data<br \/>\n      #\u524d\u5411\u8ba1\u7b97\u7684\u8fc7\u7a0b<br \/>\n      predicts &#061; model(images)<br \/>\n      #\u8ba1\u7b97\u635f\u5931<br \/>\n      loss &#061; F.cross_entropy(predicts, labels)<br \/>\n      #\u8ba1\u7b97\u51c6\u786e\u7387<br \/>\n      acc &#061; paddle.metric.accuracy(predicts, labels)<br \/>\n      accuracies.append(acc.numpy())<br \/>\n      losses.append(loss.numpy())<\/p>\n<p>avg_acc, avg_loss &#061; np.mean(accuracies), np.mean(losses)<br \/>\nprint(&#034;[validation]After epoch {}: accuracy\/loss: {}\/{}&#034;.format(epoch_id, avg_acc, avg_loss))<br \/>\n#\u8bb0\u5f55\u5f53\u524d\u6d4b\u8bd5\u96c6\u5e73\u5747 Loss \u548c\u51c6\u786e\u7387\u5230 VisualDL<br \/>\nlogwriter.add_scalar(&#034;test_avg_loss&#034;, value&#061;avg_acc, step&#061;epoch_id)<br \/>\nlogwriter.add_scalar(&#034;test_avg_acc&#034;, value&#061;avg_loss, step&#061;epoch_id)<\/p>\n<p>add_scalar \u63a5\u53e3\u5199\u5165\u7684\u6d4b\u8bd5\u96c6\u7684\u635f\u5931\u51fd\u6570\u503c\u548c\u51c6\u786e\u7387\u7684\u503c&#xff0c;\u540c\u6837\u53ef\u4ee5\u5728\u201c\u6807\u91cf\u6570\u636e\u201d\u9875\u9762\u770b\u5230\u3002\u53ef\u4ee5\u770b\u5230\u968f\u7740\u6a21\u578b\u7684\u8bad\u7ec3&#xff0c;\u6d4b\u8bd5\u96c6\u4e0a\u7684\u635f\u5931\u51fd\u6570\u503c\u4e5f\u5728\u4e0b\u964d\u5e76\u4e14\u9884\u6d4b\u51c6\u786e\u7387\u5728\u4e0d\u65ad\u7684\u5347\u9ad8&#xff0c;\u540c\u6837\u8bf4\u660e\u4e86\u6a21\u578b\u7684\u8bad\u7ec3\u7b26\u5408\u6211\u4eec\u60f3\u8981\u7684\u9884\u671f\u3002<\/p>\n<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"img\" height=\"956\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/03\/20260303012548-69a6389c96ce9.png\" width=\"1920\" \/><\/p>\n<p>\u56fe 10&#xff1a;\u67e5\u770b\u6d4b\u8bd5\u96c6\u7684\u51c6\u786e\u7387\u503c\u53d8\u5316<\/p>\n<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"img\" height=\"956\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/03\/20260303012549-69a6389d54fe1.png\" width=\"1920\" \/><\/p>\n<p>\u56fe 11&#xff1a;\u67e5\u770b\u6d4b\u8bd5\u96c6\u7684\u635f\u5931\u51fd\u6570\u503c\u53d8\u5316<\/p>\n<h5>2.3.2 \u67e5\u770b pr \u66f2\u7ebf<\/h5>\n<p>VisualDL \u53ef\u4ee5\u5728\u6bcf\u4e2a\u8bad\u7ec3\u7684 epoch \u7ed3\u675f\u540e&#xff0c;\u5728\u6d4b\u8bd5\u96c6\u4e0a\u753b\u51fa\u5bf9\u5e94\u7684 pr \u66f2\u7ebf&#xff0c;\u53c2\u7167\u4e0b\u8ff0\u4ee3\u7801&#xff0c;\u4f7f\u7528add_pr_curve\u63a5\u53e3\u8bb0\u5f55\u6bcf\u4e2a\u7c7b\u522b\u7684 pr \u66f2\u7ebf\u3002<\/p>\n<p># evaluate model after one epoch<br \/>\n    model.eval()<br \/>\n    accuracies &#061; []<br \/>\n    losses &#061; []<br \/>\n    class_probs &#061; []<br \/>\n    class_preds &#061; []<br \/>\n    for batch_id, data in enumerate(test_loader):<br \/>\n        #\u51c6\u5907\u6570\u636e<br \/>\n        images, labels &#061; data<br \/>\n        #\u524d\u5411\u8ba1\u7b97\u7684\u8fc7\u7a0b<br \/>\n        predicts &#061; model(images)<br \/>\n        #\u8ba1\u7b97\u635f\u5931<br \/>\n        loss &#061; F.cross_entropy(predicts, labels)<br \/>\n        #\u8ba1\u7b97\u51c6\u786e\u7387<br \/>\n        acc &#061; paddle.metric.accuracy(predicts, labels)<br \/>\n        accuracies.append(acc.numpy())<br \/>\n        losses.append(loss.numpy())<br \/>\n        #\u8bb0\u5f55\u7528\u4e8e\u753b pr \u66f2\u7ebf\u9700\u8981\u7684\u9884\u6d4b\u6982\u7387\u548c\u7c7b\u522b<br \/>\n        class_probs_batch &#061; [F.softmax(predict, axis&#061;0) for predict in predicts]<br \/>\n        class_preds_batch &#061; paddle.argmax(predicts, 1)<\/p>\n<p>        class_probs.append(class_probs_batch)<br \/>\n        class_preds.append(class_preds_batch)<\/p>\n<p>    test_probs &#061; paddle.concat([paddle.stack(batch) for batch in class_probs]).numpy()<br \/>\n    test_preds &#061; paddle.concat(class_preds).numpy()<\/p>\n<p>    for i in range(10):<br \/>\n      logwriter.add_pr_curve(&#039;class_{}&#039;.format(i), labels&#061;(test_preds &#061;&#061; i),predictions&#061;test_probs[:,i], step&#061;epoch_id)<\/p>\n<p>\u5728\u201c\u66f4\u591a\u00b7PR \u66f2\u7ebf\u201d\u9875\u9762\u663e\u793a\u4e86\u6240\u8ba1\u7b97\u7684\u6bcf\u4e2a\u7c7b\u522b\u7684 PR \u66f2\u7ebf\u3002\u53ef\u4ee5\u89c2\u5bdf\u6d4b\u8bd5\u96c6\u4e0a\u7684 PR \u66f2\u7ebf\u968f\u7740\u8bad\u7ec3\u8fc7\u7a0b\u7684\u53d8\u5316\u60c5\u51b5&#xff0c;\u4ee5\u53ca\u5bf9\u6bd4\u4e0d\u540c\u7c7b\u522b\u4e0b PR \u66f2\u7ebf\u7684\u5dee\u5f02\u3002<\/p>\n<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"img\" height=\"952\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/03\/20260303012550-69a6389e309c1.png\" width=\"1920\" \/><\/p>\n<p>\u56fe 12&#xff1a;\u67e5\u770b PR \u66f2\u7ebf<\/p>\n<h4>2.4 \u66f4\u591a\u7528\u6cd5<\/h4>\n<p>\u4ee5\u4e0a\u4ecb\u7ecd\u4e86\u5982\u4f55\u7ed3\u5408 VisualDL \u53ef\u89c6\u5316\u5de5\u5177\u6765\u8f85\u52a9\u60a8\u8fdb\u884c\u7f51\u7edc\u6a21\u578b\u7684\u8bad\u7ec3\u3002\u8fd8\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u8981&#xff0c;\u52a0\u5165\u4efb\u4f55\u60f3\u8981\u89c2\u5bdf\u7684\u6570\u636e\u3002\u66f4\u591a\u7684\u5199\u5165\u63a5\u53e3\u8bf4\u660e\u53ef\u4ee5\u53c2\u8003VisualDL \u7684\u5b98\u65b9\u6587\u6863\u3002\u6b64\u5916&#xff0c;\u53ef\u4ee5\u5728 Paddle \u5b98\u7f51\u4f53\u9a8c VisualDL \u5168\u529f\u80fd\u5c55\u793a\u7684demo\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528 VisualDL \u53ef\u89c6\u5316\u6a21\u578b&#xff0c;\u6570\u636e\u548c\u8bad\u7ec3<br \/>\n\u5728\u6784\u5efa\u624b\u5199\u6570\u5b57\u8bc6\u522b\u6a21\u578b\u6559\u5b66\u6848\u4f8b\u4e2d&#xff0c;\u4ecb\u7ecd\u4e86\u5982\u4f55\u4f7f\u7528\u98de\u6868\u7684 paddle.io \u8fdb\u884c\u6570\u636e\u5904\u7406&#xff0c;\u901a\u8fc7 paddle.nn \u6784\u5efa\u6a21\u578b&#xff0c;\u4ee5\u53ca\u5982\u4f55\u5728\u8bad\u7ec3\u6570\u636e\u4e0a\u8fdb\u884c\u6a21\u578b\u7684\u8bad\u7ec3\u548c\u5728\u6d4b\u8bd5\u6570\u636e\u4e0a\u5bf9\u6a21\u578b\u6548\u679c\u8fdb\u884c\u8bc4\u4f30\u3002\u4e3a\u4e86\u4e86\u89e3\u6a21\u578b\u7684\u8bad\u7ec3\u8fc7\u7a0b&#xff0c;\u4e4b\u524d\u901a\u8fc7\u6253\u5370\u635f\u5931\u51fd\u6570 loss \u7684\u503c\u6765\u89c2\u5bdf\u53d1\u751f\u7684\u53d8\u5316&#xff0c;\u4f46\u662f\u8fd9\u79cd\u89c2\u6d4b\u65b9\u5f0f\u975e\u5e38\u4e0d\u76f4\u89c2\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528\u98de\u6868\u7684\u53ef\u89c6\u5316\u5de5\u5177 Vis<\/p>\n","protected":false},"author":2,"featured_media":79831,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[6842,50,132,207,78],"topic":[],"class_list":["post-79844","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-paddlepaddle","tag-50","tag-132","tag-207","tag-78"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4f7f\u7528 VisualDL \u53ef\u89c6\u5316\u6a21\u578b\uff0c\u6570\u636e\u548c\u8bad\u7ec3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/79844.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4f7f\u7528 VisualDL \u53ef\u89c6\u5316\u6a21\u578b\uff0c\u6570\u636e\u548c\u8bad\u7ec3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4f7f\u7528 VisualDL \u53ef\u89c6\u5316\u6a21\u578b&#xff0c;\u6570\u636e\u548c\u8bad\u7ec3 \u5728\u6784\u5efa\u624b\u5199\u6570\u5b57\u8bc6\u522b\u6a21\u578b\u6559\u5b66\u6848\u4f8b\u4e2d&#xff0c;\u4ecb\u7ecd\u4e86\u5982\u4f55\u4f7f\u7528\u98de\u6868\u7684 paddle.io \u8fdb\u884c\u6570\u636e\u5904\u7406&#xff0c;\u901a\u8fc7 paddle.nn \u6784\u5efa\u6a21\u578b&#xff0c;\u4ee5\u53ca\u5982\u4f55\u5728\u8bad\u7ec3\u6570\u636e\u4e0a\u8fdb\u884c\u6a21\u578b\u7684\u8bad\u7ec3\u548c\u5728\u6d4b\u8bd5\u6570\u636e\u4e0a\u5bf9\u6a21\u578b\u6548\u679c\u8fdb\u884c\u8bc4\u4f30\u3002\u4e3a\u4e86\u4e86\u89e3\u6a21\u578b\u7684\u8bad\u7ec3\u8fc7\u7a0b&#xff0c;\u4e4b\u524d\u901a\u8fc7\u6253\u5370\u635f\u5931\u51fd\u6570 loss \u7684\u503c\u6765\u89c2\u5bdf\u53d1\u751f\u7684\u53d8\u5316&#xff0c;\u4f46\u662f\u8fd9\u79cd\u89c2\u6d4b\u65b9\u5f0f\u975e\u5e38\u4e0d\u76f4\u89c2\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528\u98de\u6868\u7684\u53ef\u89c6\u5316\u5de5\u5177 Vis\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/79844.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-03-03T01:25:51+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/03\/20260303012544-69a638981bc5b.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/79844.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/79844.html\",\"name\":\"\u4f7f\u7528 VisualDL \u53ef\u89c6\u5316\u6a21\u578b\uff0c\u6570\u636e\u548c\u8bad\u7ec3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-03-03T01:25:51+00:00\",\"dateModified\":\"2026-03-03T01:25:51+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/79844.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/79844.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/79844.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4f7f\u7528 VisualDL \u53ef\u89c6\u5316\u6a21\u578b\uff0c\u6570\u636e\u548c\u8bad\u7ec3\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u4f7f\u7528 VisualDL \u53ef\u89c6\u5316\u6a21\u578b\uff0c\u6570\u636e\u548c\u8bad\u7ec3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/79844.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4f7f\u7528 VisualDL \u53ef\u89c6\u5316\u6a21\u578b\uff0c\u6570\u636e\u548c\u8bad\u7ec3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4f7f\u7528 VisualDL \u53ef\u89c6\u5316\u6a21\u578b&#xff0c;\u6570\u636e\u548c\u8bad\u7ec3 \u5728\u6784\u5efa\u624b\u5199\u6570\u5b57\u8bc6\u522b\u6a21\u578b\u6559\u5b66\u6848\u4f8b\u4e2d&#xff0c;\u4ecb\u7ecd\u4e86\u5982\u4f55\u4f7f\u7528\u98de\u6868\u7684 paddle.io \u8fdb\u884c\u6570\u636e\u5904\u7406&#xff0c;\u901a\u8fc7 paddle.nn \u6784\u5efa\u6a21\u578b&#xff0c;\u4ee5\u53ca\u5982\u4f55\u5728\u8bad\u7ec3\u6570\u636e\u4e0a\u8fdb\u884c\u6a21\u578b\u7684\u8bad\u7ec3\u548c\u5728\u6d4b\u8bd5\u6570\u636e\u4e0a\u5bf9\u6a21\u578b\u6548\u679c\u8fdb\u884c\u8bc4\u4f30\u3002\u4e3a\u4e86\u4e86\u89e3\u6a21\u578b\u7684\u8bad\u7ec3\u8fc7\u7a0b&#xff0c;\u4e4b\u524d\u901a\u8fc7\u6253\u5370\u635f\u5931\u51fd\u6570 loss \u7684\u503c\u6765\u89c2\u5bdf\u53d1\u751f\u7684\u53d8\u5316&#xff0c;\u4f46\u662f\u8fd9\u79cd\u89c2\u6d4b\u65b9\u5f0f\u975e\u5e38\u4e0d\u76f4\u89c2\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528\u98de\u6868\u7684\u53ef\u89c6\u5316\u5de5\u5177 Vis","og_url":"https:\/\/www.wsisp.com\/helps\/79844.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-03-03T01:25:51+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/03\/20260303012544-69a638981bc5b.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"7 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/79844.html","url":"https:\/\/www.wsisp.com\/helps\/79844.html","name":"\u4f7f\u7528 VisualDL \u53ef\u89c6\u5316\u6a21\u578b\uff0c\u6570\u636e\u548c\u8bad\u7ec3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-03-03T01:25:51+00:00","dateModified":"2026-03-03T01:25:51+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/79844.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/79844.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/79844.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4f7f\u7528 VisualDL \u53ef\u89c6\u5316\u6a21\u578b\uff0c\u6570\u636e\u548c\u8bad\u7ec3"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/79844","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=79844"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/79844\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/79831"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=79844"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=79844"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=79844"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=79844"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}