Yaohong

为了真相不惜被羞辱

SSLCertVerificationError报错

双击执行Applications > Python3.6 下的Install Certificates.command

SSLCertVerificationError报错

Error:

ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)

Solution: 环境:Mac

Macintosh HD > Applications > Python3.6 (或者其它安装python目录)
然后:双击 Install Certificates.command

Double click Install Certificates.command log:

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
/Applications/Python\ 3.7/Install\ Certificates.command ; exit;
macdeMacBook-Air-5:~ Rhys$ /Applications/Python\ 3.7/Install\ Certificates.command ; exit;
 -- pip install --upgrade certifi
Requirement already up-to-date: certifi in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (2020.6.20)
WARNING: You are using pip version 20.1.1; however, version 20.2.4 is available.
You should consider upgrading via the '/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -m pip install --upgrade pip' command.
 -- removing any existing file or link
 -- creating symlink to certifi certificate bundle
 -- setting permissions
 -- update complete
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
Deleting expired sessions...68 completed.

[Process completed]

Double click Update Shell Profile.command log:


简单的图像加宽和截取类

支持图像加宽高,或截掉宽高

简单的图像加宽和截取类

源码如下:

class ImageUtils:

	def __init__(self):
		import numpy;
		self.np = numpy;
		pass

	## 
	def resizePadding(self, np_2d_image, target_width,target_height):
		single_img 		= np_2d_image;
		tmp_img_width 	= single_img.shape[1]
		tmp_img_height 	= single_img.shape[0]
		np 				= self.np
		print("resizeFile origin shape :",single_img.shape)
		# 宽度pading添加
		if tmp_img_width < target_width:
			for x in range(tmp_img_width, target_width):
				# tmp_arr    = np.arange(255,255,(len(single_img),1));
				if x%2 == 0:
					single_img = np.insert(single_img, 0, 255,axis=1);
				else:
					single_img = np.insert(single_img, single_img.shape[1], 255,axis=1);
				# print(file_name_prefix, "origin shape :",single_img.shape)
		# 高度pading添加
		if tmp_img_height < target_height:
			for x in range(tmp_img_height, target_height):
				# tmp_arr    = np.arange(255,255,(len(single_img),1));
				if x%2 == 0:
					single_img = np.insert(single_img, 0, 255,axis=0);
				else:
					single_img = np.insert(single_img, single_img.shape[0], 255,axis=0);

		# 宽度截掉
		if tmp_img_width > target_width:
			for x in range(target_width, tmp_img_width):
				if x%2 == 0:
					single_img = np.delete(single_img, 0, axis=1);
				else:
					single_img = np.delete(single_img, single_img.shape[1]-1, axis=1);

		# 高度截掉
		if tmp_img_height > target_height:
			for x in range(target_height, tmp_img_height):
				if x%2 == 0:
					single_img = np.delete(single_img, 0, axis=0);
				else:
					single_img = np.delete(single_img, single_img.shape[0]-1, axis=0);


		print("resizeFile after shape :",single_img.shape)
		return single_img;

调用代码


如何计算一个卷积层的参数?

卷积层参数=(卷积长x卷积宽x卷积通道数+1)x卷积深度

如何计算一个卷积参数?

在计算卷积参数前,我们先来看几个小问题。

1.怎么判断一个卷积核有多少通道?

一个卷积核的通道数=前一层的通道数; 比如前一层是64x64x3的图像,那卷积核的通道数就是3层。

2.怎么理解卷积核数量和卷积核通道数?

如果把一个卷积核比喻成一本书,那卷积核的通道数就是一本书的页数。


如何计算全连接神经元参数

当前层的全连接参数=上一层神经元数x当前神经元数+当前神经偏移值数量

如何计算全连接神经元参数?

模型源码为:

from tensorflow.keras import models
from tensorflow.keras import layers
network = models.Sequential()
network.add(layers.Dense(504, activation='relu', input_shape=(504,)))
network.add(layers.Dense(11, activation='softmax'))
network.summary()

输出:

Model: "sequential"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
dense (Dense)                (None, 504)               254520    
_________________________________________________________________
dense_1 (Dense)              (None, 11)                5555      
=================================================================
Total params: 260,075
Trainable params: 260,075
Non-trainable params: 0
_________________________________________________________________

在第一行中,dense中的254520是怎么计算呢? 其计算方式如下:


Tensorflow 保存和加载model

Tensorflow 保存和加载model

保存model的代码:

import tensorflow as tf
save_model_path 	= "/save_model" # 保存的文件夹路径
network.save(save_model_path);

保存的目录格式如下,期中saved_model.pb是主要的文件:

save_model
	-- assets
	-- variables
		-- variables.data-00000-of-00001
		-- variables.index
	-- saved_model.pb

加载model如下:


一条微信消息在网络层的历程

简单理解网络模型

一条微信消息在网络层的历程

当我们向朋友发送一条微信文字消息时,我们的操作仅仅是让手机连上网,通过连接WIFI或使用移动网络,然后在手机上打字“明天跑步去吗?”,最后点击发送按钮。


PHP autoload

更新中...

php autoload

In general, when we use a file which not include in current file, we need to load it in current file by using require or include;

But when a project has a lot of php files, it is not a good way to include each file manually.

Let’s see a simple code:

<?php
$person = new Person("Rhys", 20);

var_dump($person);

There is a new class Person which didn’t be load in current file. In this case, php will call default autoload method spl_autoload() in order to load possible class;


JAVA 序列化

JAVA 序列化

Java编译过程

Java源码-> javac将源码转换成class 文件->java命令执行 class 文件;

方法中的“ T”用途是什么?

在查看别人的源码时,会看到如下的代码:


Some notes on Convolution Course

Some notes on Convolution course

What is padding?

Padding is to add some pixels to the border of the original image, such as a 6*6 image will become a 8*8 image if we add a pixel to its border.

valid convolution vs same convolution.

Valid convolution is on padding that means the actual pixels of the output image after we convole original image with filter.

Same convolution means adding padding so that the output image has the same size as its input image.


My Little Baby

My Little Baby

My wife and I went to hostipal because she felt pain in womb on 6 May. The doctor advised hostipalization for her. She felt pain more frequenctly at that night. Doctors gave her a anesthetic that make her felt less pain.

She was ready to give birth a baby on the next day morning. I was waiting beside the door of delivery room. After two hours, a nurse opened the door and told me that my wife had given birth to a baby successfully. I was so happy at that time.