def one_hot_encoder(raw_y):result=[]for i in raw_y:#1-10y_temp=np.zeros(10)#1行10列0向量y_temp[i-1]=1result.append(y_temp)#一行一行写入,每一行都仅有一个1,循环写入5000次return np.array(result)结果[[0.0.0....0.0.1.][0.0.0....0.0.1.][0.0.0....0.0.1.]...[0.0.0....0.1.0.][0.0.0....0.1.0.][0.0.0....0.1.0.]]
"""
可视化隐藏层
"""
def plot_hidden_layer(theta):theta1,_=deserialize(theta)hidden_layer=theta1[:,1:]fig, ax = plt.subplots(figsize=(8,8), nrows=5, ncols=5, sharey=True, sharex=True)plt.xticks([])plt.yticks([])for r in range(5):for c in range(5):ax[r, c].imshow(hidden_layer[5* r + c].reshape(20,20).T, cmap="gray_r")plt.show()
一、归并排序的简述
归并排序(Merge Sort)是一种高效的排序算法,采用分治法(Divide and Conquer)的策略。它的基本思想是将一个大的问题分解成多个小问题,然后解决这些小问题,最后将结果合并起…