python - Spyder 编译器显示错误的输出
问题描述
所以我试图运行以下代码:
import numpy as np
import numpy.linalg as la
x = np.array ( [ [1, 0, 1], [0, 1, 1], [0, 0, 1], [1, 1, 1]] )
y = np.array ( [1, 1, 0, 0] )
# solve using normal equations:
x_transpose = np.transpose(x) #calculating transpose
x_transpose_dot_x = x_transpose.dot(x) # calculating dot product
temp_1 = la.inv(x_transpose_dot_x) #calculating inverse
temp_2 = x_transpose.dot(y)
theta = temp_1.dot(temp_2)
print(theta)
使用 spyder IDE 的输出:
[2.22044605e-16 1.11022302e-16 5.00000000e-01]
使用 collab 或 py IDE 的输出:
[0.00000000e+00 2.22044605e-16 5.00000000e-01]
为什么 spyder 会产生错误的输出?我喜欢使用 spyder !
解决方案
推荐阅读
- mysql - MySQL如何选择group by中的第一个非空值
- asp.net - 使用服务标识时无法连接到 Azure Key Vault
- google-api - Google Cloud Storage SDK(Java) 随机调用 IP addersses,而不是用 google 域覆盖该调用
- java - 不使用 MNIST 的 TensorFlow 初学者示例
- java - saveOrUpdate 在带有 H2 数据库的 Spring Data 中不起作用
- php - PHP Foreach 循环 - 缺少数据 - 如何使用“无数据”响应而不是收到警告来创建
- django - When() 条件表达式中的正则表达式注释
- sql - 在 Postresql 中加入最大记录
- javascript - 引导树视图不显示树
- twitter-bootstrap - 如何将引导按钮定位到导航选项卡的右侧?