The use of matplotlib in deep learning is enough for me

I think the matplotlib library will be used, as long as it can meet the needs of daily deep learning, it will be
supplemented and updated one after another. . . . . .

1. Line chart

plt.figure() creates a frame for display, the first parameter is several frames, the second is the size of the frame

import matplotlib.pyplot as plt
plt.figure(1, figsize=(10, 5))  //创建第一个窗口
plt.figure(2, figsize=(1, 5))  //创建第二个窗口
plt.show()

insert image description here
plt.subplot() creates a subplot in the current frame,
plt.xlabel() and plt.ylabel() respectively set the x-axis and y-axis labels
plt.xticks() and plt.yticks() set the x-axis, y The axis pair is replaced by the position of the scale with the label we want to set

import matplotlib.pyplot as plt
plt.figure(1, figsize=(10, 5))  
plt.subplot(1, 2, 1)
plt.xlabel("hahaha")
plt.xticks([0, 0.5, 1], ["deep", "***", "learning"]) //将原图图x轴的00.51刻度处换成我们的label
plt.subplot(1, 2, 2)
plt.figure(2, figsize=(1, 5))  //第二个图框下没有创建子图,所以show出来以后还是空白
plt.show()

insert image description here

plt.title() When the subgraph label
plt.plot() draws a line graph, parameters: independent variable x, the value of the corresponding function y, and the color of the line and label value (used to display the legend)
plt.legend() the legend Displayed when the show comes out

plt.figure(1, figsize=(10, 5))
plt.subplot(1, 2, 1)
plt.title("loss")  //第一个图框下的第一个子图标题

plt.plot(x, loss_file_no_fc_freeze_value, color='red', label='freeze_conv')
plt.plot(x, loss_no_fc, color='blue', label='no_freeze')
plt.plot(x, ResNet_loss_list_value, color='black', label='initial_weight')
plt.legend()   //这是显示图例,在plot画图中设置不同的label,就会根据每条线显示出图例

The following is when I am training the deep learning model, I record the loss and accuracy of each epoch through the dictionary file, and visualize it with matplotlib

plt.figure(1, figsize=(10, 5))  //第一个图框figure1
//第一个子图
plt.subplot(1, 2, 1)
plt.title("loss") //标题
plt.xlabel("num of epoch") //x轴标签
plt.ylabel("value of loss")  //y轴标签
plt.xticks([5, 10, 15, 20], ["A", "B", "C", "D"])  //将原图中5, 10, 15, 20刻度处换成我们的label
plt.plot(x, loss_file_no_fc_freeze_value, color='red', label='freeze_conv')
plt.plot(x, loss_no_fc, color='blue', label='no_freeze')
plt.plot(x, ResNet_loss_list_value, color='black', label='initial_weight')
plt.legend() //根据plot绘图中每个线的color和label显示图例
#
//第二个子图
plt.subplot(1, 2, 2)
plt.title("accruacy")
plt.plot(x, accuracy_file_no_fc_freeze, color='red', label='freeze_conv')
plt.plot(x, accuracy_file_no_fc, color='blue', label='no_freeze')
plt.plot(x, ResNet_accuracy_list_value, color='black', label='initial_weight')
plt.legend()
plt.show()

insert image description here

2. Scatterplot

3. Histogram

insert image description here

Guess you like

Origin blog.csdn.net/weixin_50557558/article/details/128145594