Depth learning portal 7 -CV epidemic featurette camped experience -alading


2020/03/16 - 2020/08/31

Use PaddlePaddle depth study

A week-long training camp depth study ended, for each harvest from start to finish took part in the training camp of the students are certainly many. This time I will summarize the following aspects about the ideas and experience.
PaddlePaddle official website address
Baidu AIStudio official website URL now have to send force GPU card count Oh, really a lot faster than the speed of running on my little laptop!
7th Battalion punch address curriculum can long-term repeated learning Oh, because it is pure dry goods, if the entry is white, then listen to it again is definitely not enough.

Depth learning method

1, a solid foundation, the earth was shaking. This is my greatest experience. Depth study is not a traditional C, C ++ and other languages to learn, running through the code base to know about what it means, but must first get to know the principles, and then enter the code to understand the model, or directly on the code, it will call you confused, preparation is very important.

2, must be python numpy syntax and libraries to be very skilled , skilled standard is the code to knock, more practice, the python lists, dictionaries, tuples out a will immediately be able to know the data looks like, a few dimensional matrix each dimension are what, etc. (otherwise transfer some interfaces are not up, because you do not know the interface need to pass parameters look like, but also what data is returned to pick up the data, etc.), I'm from C ++ to Python to learn, at first thought to be not much difficulty, after all, the C ++ Tulong can play this dynamic, Python scripting language should be not much problem, but understand the middle and still have very skilled big gap.

3, theory and practice. I started to look at is Andrew Ng video course focuses on the feeling of foreigners are finally thrown in front of you constantly have to continue to pave the way, I heard the greatest feeling of course is Andrew Ng, his every word I can understand, listen to understand, but watching the video, I seemed to know nothing. (Andrew Ng's class is still very good, many teachers recommend their students to see, my roommate saw a semester.) Later, after another course Baidu saw some depth learning. All of a sudden in-depth understanding of the process and focus on problem solving depth study, I like to do technical people speak theory, it is easy to hear and focus on pain points, like most directly speak to follow the code feel great God go together, usually half a day to see their own can not read code, the teacher in the process of feeling does not seem so difficult. After the completion of the entire study and understand the most simple Perceptron, DNN, CNN, the simple entry-CV, will simply debug code.

4, constant practice I remember my C ++ teacher said, the level of your level that you stick in this field length, instead of watching how smart individual, often insist on much more important than smart. In depth study, insisted no doubt very important, continue to look at some papers, look at some models, calculate parameters, to strengthen the probability theory, long-term adherence, the ability to put up step by step. (The words are from the end of the punch camp starting today, I did not go downstairs the whole week, although at home, but the same every day with the war, have to say inside the camp is really strong learning atmosphere, this atmosphere servant progress the speed is very fast just like the week before the final exam efficiency review of the same - soar).

The main learning content

day1: new crown epidemic visual
day2: gesture recognition
day3: License Plate Recognition
day4: Masks Category
day5: flow classifier game
day6: paddlehub and paddleslim introduction and use

Daily learning summary

day1: new crown epidemic visualization

In accordance with what they learn in class, crawling statistics on March 31 the same day lilac garden open, according to the cumulative number of confirmed using pyecharts draw epidemic distribution, as shown below, submit screenshots. Pycharts api refer to: https: //pyecharts.org/#/zh-cn/

The main learning to use the data to draw the data shown in the figure.

import json
import datetime
from pyecharts.charts import Map
from pyecharts import options as opts
from pyecharts.charts import Pie

# 读原始数据文件
today = datetime.date.today().strftime('%Y%m%d')   #20200331
datafile = 'data/'+ today + '.json'
with open(datafile, 'r', encoding='UTF-8') as file:
    json_array = json.loads(file.read())

# 分析全国实时确诊数据:'confirmedCount'字段
china_data = []
for province in json_array:
    china_data.append((province['provinceShortName'], province['confirmedCount']))
china_data = sorted(china_data, key=lambda x: x[1], reverse=True)                 #reverse=True,表示降序,反之升序

print(china_data)
# 全国疫情地图
# 自定义的每一段的范围,以及每一段的特别的样式。
pieces = [
    {'min': 10000, 'color': '#540d0d'},
    {'max': 9999, 'min': 1000, 'color': '#9c1414'},
    {'max': 999, 'min': 500, 'color': '#d92727'},
    {'max': 499, 'min': 100, 'color': '#ed3232'},
    {'max': 99, 'min': 10, 'color': '#f27777'},
    {'max': 9, 'min': 1, 'color': '#f7adad'},
    {'max': 0, 'color': '#f7e4e4'},
]
labels = [data[0] for data in china_data]
counts = [data[1] for data in china_data]

m = Pie()
m.add("累计确诊", [list(z) for z in zip(labels, counts)])

# 系列配置项,可配置图元样式、文字样式、标签样式、点线样式等
m.set_series_opts(label_opts=opts.LabelOpts(font_size=12),is_show=False)

# #全局配置项,可配置标题、动画、坐标轴、图例等
m.set_global_opts(title_opts=opts.TitleOpts(title='全国实时确诊数据',
                                            subtitle='数据来源:丁香园'),
                  legend_opts=opts.LegendOpts(is_show=False),
                  visualmap_opts=opts.VisualMapOpts(pieces=pieces,
                                                    is_piecewise=True,   #是否为分段型
                                                    is_show=True))       #是否显示视觉映射配置
# #render()会生成本地 HTML 文件,默认会在当前目录生成 render.html 文件,也可以传入路径参数,如 m.render("mycharts.html")
m.render(path='data/全国实时确诊数据.html')

Here Insert Picture Description
day2 gesture recognition (fully connected neural network learning + practice)

1, the code completion and successful operation of 2, tune parameters, optimization, improve test set reserve ratio

The main part is defined DNN network model to calculate the number of neurons in each layer and tuning.

# 定义DNN网络
class MyDNN(fluid.dygraph.Layer):
    def __init__(self,name_scope):
        super(MyDNN, self).__init__(name_scope)
        # 定义4层全连接隐含层,输出维度是10,激活函数为sigmoid
        self.fc1 = Linear(input_dim=30000, output_dim=100, act='sigmoid')  # 隐含层节点为10,可根据任务调整
        self.fc2 = Linear(input_dim=100, output_dim=100, act='sigmoid')
        self.fc3 = Linear(input_dim=100, output_dim=100, act='sigmoid')
        # 定义一层全连接输出层,输出维度是1,不使用激活函数
        self.fc4 = Linear(input_dim=100, output_dim=10, act='softmax')
    def forward(self,inputs,label=None):
        inputs = fluid.layers.reshape(inputs, [inputs.shape[0], 30000])
        outputs1 = self.fc1(inputs)
        outputs2 = self.fc2(outputs1)
        outputs3 = self.fc3(outputs2)
        y = self.fc4(outputs3)
        return y

day 3 License Plate Recognition (convolution neural network learning + practice)

1, the code completion and successful operation of 2, tune parameters, optimization, improve the accuracy of the test set

The main part is defined CNN network model to calculate the number of neurons in each layer and tuning.

#定义网络
class MyLeNet(fluid.dygraph.Layer):
    def __init__(self):
        super(MyLeNet, self).__init__()
        self.hidden1_1 = Conv2D(1, 28, 5, 1)  # 通道数、卷积核个数、卷积核大小
        self.hidden1_2 = Pool2D(pool_size=2, pool_type='max', pool_stride=1)
        self.hidden2_1 = Conv2D(28, 32, 3, 1)
        self.hidden2_2 = Pool2D(pool_size=2, pool_type='max', pool_stride=1)
        self.hidden3 = Conv2D(32, 32, 3, 1)
        self.hidden4 = Linear(32 * 10 * 10, 65, act='softmax')

    def forward(self, input):
        # print(input.shape)
        x = self.hidden1_1(input)
        # print(x.shape)
        x = self.hidden1_2(x)
        # print(x.shape)
        x = self.hidden2_1(x)
        # print(x.shape)
        x = self.hidden2_2(x)
        # print(x.shape)
        x = self.hidden3(x)
        # print(x.shape)
        x = fluid.layers.reshape(x, shape=[-1, 32 * 10 * 10])
        y = self.hidden4(x)
        return y

Day4 mask identification (using Model VGG)

1, the code is run through, please according to what they have learned in class content, code completion VGGNet class structure VGG network to ensure that the program runs through. On the basis of the successful construction of VGG on, try to construct other networks.
2, hands tuning and tuning Reflections, in order to verify the accuracy of rate on the current evaluation, the higher the accuracy of the current, the higher the score verification!

# VGG网络模型定义

class VGGNet(fluid.dygraph.Layer):
    def __init__(self):
        super(VGGNet, self).__init__()
        self.convpool01 = ConvPool(
            3, 64, 3, 2, 2, 2, act="relu"
        )
        self.convpool02 = ConvPool(
            64, 128, 3, 2, 2, 2, act="relu"
        )
        self.convpool03 = ConvPool(
            128, 256, 3, 2, 2, 3, act="relu"
        )
        self.convpool04 = ConvPool(
            256, 512, 3, 2, 2, 3, act="relu"
        )
        self.convpool05 = ConvPool(
            512, 512, 3, 2, 2, 3, act="relu"
        )
        self.pool_5_shape = 512 * 7 * 7
        self.fc01 = fluid.dygraph.Linear(self.pool_5_shape, 4096, act="relu")
        self.fc02 = fluid.dygraph.Linear(4096, 4096, act="relu")
        self.fc03 = fluid.dygraph.Linear(4096, 2, act="softmax")

    #  前向计算
    def forward(self, inputs, label=None):
        out = self.convpool01(inputs)
        out = self.convpool02(out)
        out = self.convpool03(out)
        out = self.convpool04(out)
        out = self.convpool05(out)

        out = fluid.layers.reshape(out, shape=[-1, 512 * 7 * 7])
        out = self.fc01(out)
        out = self.fc02(out)
        out = self.fc03(out)

        if label is not None:
            acc = fluid.layers.accuracy(inputs=out, label=label)
            return out, acc
        else:
            return out

Day5 flow density detecting (Event)

Asked participants to give a model or algorithm, for a given picture, the total number of statistical picture. Given the picture data, whereby the players training model for each test data to predict the most accurate number.
Basic version Reference https://aistudio.baidu.com/aistudio/projectdetail/382039 (also can click a link)

Tuning focus: learning rate, the number of training rounds, discard rate, change the model and so on.

Resource Reviews

1, GPU count of the card using the experience: GPU than the CPU too much incense. Especially the more rounds speed train, the more complex the model, the more significant this advantage reflected. But this time the number of training camp is too many, GPU resources during the day is not always grab on. In order to use GPU, one day I tune up 4:00 Code, also gave all ...

2, open-source AI studio on a lot of projects, some students open their own, some teachers Daniel openly, but all can fork into their own folder, run and debug. AI Studio project portal https://aistudio.baidu.com/aistudio/projectoverview/public (also can click a link)

3, API documentation, you have to look at, in time to see the meaning of each parameter do not know which, but also know that this interface is mainly what to do. Professional documents look is very painful, but there is time to see a harvest, or to insist on watching.
Quick Start portal https://www.paddlepaddle.org.cn/documentation/docs/zh/beginners_guide/index_cn.html (also can click a link)

4, installed on the local use my own habits is more like local programming (very traditional thinking), jupyter notebook is not very common, if you want to install to the local environment, can choose their own local environment matches, and then follow the installation tutorial tips step by step installation. TIPS: best not to tensorflow caffe paddle mounted together, these libraries in the name of some of the interface is the same, when you call sometimes ambiguous. For example, when there is no import library, direct call interface will prompt you to choose a library to an embarrassing wrong.
Quick Installation Guide https://www.paddlepaddle.org.cn/install/quick (you can also click the link)
Here Insert Picture DescriptionAdd Tsinghua source download will soon (will be very effective lifting speed):

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/Paddle/
conda config --set show_channel_urls yes

Verify successful installation

Use python3 into the python interpreter input import paddle.fluid, then enter paddle.fluid.install_check.run_check ().
If Your Paddle Fluid appear is installed successfully !, you have successfully installed.

thank

1, training camp teacher (Fall in love dandelion) and small brothers assistant really NICE, I even feel they work harder than the students in the class. Baidu employees really admire very much.
2, talk about practical classes every day little brother and little sisters, good technology, super low-key, very clear lectures, students on the basis of zero-entry is very dry. Scripts do not speak, do not sell, the only hope is to let our star lit it on github, is this a big deal, arrange ~~
3, finally, I really want to say to a teacher Sun Gaofeng: I really do your fans ~

Follow-up

1, I heard Python base camp, reproduce camp papers, hands-CV Technical Battalion, later gradually will be introduced.
2, if students want to join the TA team, you can find little sister teacher registration.
3, there will be three days of training camp every year the line, there will be time to notice released this year, a conservative estimate for the second half. (I'm looking forward to it ~)
4, there are a lot of groups and micro-channel QQ group can join, there are many great God, and technical atmosphere is very strong, the class teacher will publish the latest notifications in each group, plus a fine. I made during training in the group and discussed a lot of problems in the area, each can be an effective response, the heart is really very satisfied, very like the feeling with you together.

Published an original article · won praise 0 · Views 7

Guess you like

Origin blog.csdn.net/qq_38395721/article/details/105362986