谁能帮我运行一个程序 我的缺少numpy包 现在安装需要很长时间
谁能帮我运行一个程序 我的缺少numpy包 现在安装需要很长时间谁能帮我运行一下我看看结果import sys
import time
import math
import datetime
import threading
import numpy asnp
import matplotlib.pyplot as plt
def show_data(x,y):
num_list_x = np.arange(len(x))
plt.figure(figsize=(20, 10))
plt.xlim(0, len(num_list_x)+50)
plt.plot(num_list_x, x, color='b',linestyle='-', label='x')
plt.legend()
plt.show()
if y != None:
plt.figure(figsize=(20, 10))
num_list_y = np.arange(len(y))
plt.xlim(0, len(num_list_y)+50)
plt.plot(num_list_y, y, color='r',linestyle='-', label='y')
plt.legend()
plt.show()
def logistic(t):
return 1.0/(1+np.exp(-t))
def n_multiply(t, x):
return t * x
def trans_inverse(x):
if not isinstance(x, np.ndarray):
x = np.array(x)
return np.linalg.inv(x.transpose())
def ica(x):
m = len(x) # 样本数目,这里是 2 个
n = len(x) # mic 数目,这里是 1000 个
# 建立个 1000*1000 的列表
w = [*n for t in range(n)]
# 建立个 1000*1000 的列表
iw = [*n for t in range(n)]
# 建立个 1000*1000 的列表
w1 = [*n for t in range(n)]
# 将对角线初始化为1
for i in range(n):
w = 1
# 初始化学习率为
alpha = 0.001
# shuffle(x)
# 迭代次数最多不超过 200 次
for time in range(200):
# 分离出"样本数目"个样本
for i in range(m):
for j in range(n):
t = np.dot(w, x)
t = 1 - 2*logistic(t)
w1 = n_multiply(t,x)# w1 = t*x
iw = trans_inverse(w) # iw = w^T^(-1)
iw = w1 + iw
w1 = np.add(w1, iw) #w1 += iw
w1 = np.dot(w1, alpha)
w = np.add(w, w1)
print (time, ":\t", w)
return w
def mix(A, x,y):
mix = np.dot(A, np.array())
for i in xrange(len(mix)):
mix = mix + mix
#show_data(mix, None)
return mix
def decode(w,x):
ps = np.dot(x, w)
return ps, ps
if __name__ =="__main__":
s1 =
s2 = * 20
#s1 =
#s2 = * 2
#show_data(s1, s2)
你可以用国内源安装呀 import numpy asnp
as 与 np 之间少个空格。 去找小甲鱼文档的bs4,那里面有一个镜像,复制下来加上的话安装numpy会加速很多 两三分钟内基本能够安装完 本帖最后由 weiter 于 2020-4-23 21:36 编辑
python -m pip install numpy-python -i https://pypi.tuna.tsinghua.edu.cn/simple
这个是镜像,安装的时候就用这个(可能numpy-python得把-python删掉)
另:最后的 show_data(s1, s2) 前 去掉 井号后的结果。 好的 谢谢谢谢 weiter 发表于 2020-4-23 21:23
去找小甲鱼文档的bs4,那里面有一个镜像,复制下来加上的话安装numpy会加速很多
好的 谢谢谢谢 GIAAKK 发表于 2020-4-23 21:33
好的 谢谢谢谢
我电脑有问题运行不了的,只能帮你到这了,尽快下好numpy{:10_305:}
页:
[1]