这已经成为一个非常令人沮丧的问题,但我已经在Coursera讨论中提出要求,他们也无济于事.以下是问题:

我现在已经错了6次了.如何规范化功能?这些都是我要求的提示.
我假设x_2 ^(2)是值5184,除非我添加1的x_0列,他们没有提及,但在谈论创建设计矩阵X时他肯定会在讲座中提到.在这种情况下x_2 ^(2)将是值72.假设一个或另一个是正确的(我正在玩一个猜谜游戏),我应该用什么来规范化它?他讲述了在讲座中规范化的3种不同方式:一种使用最大值,另一种使用最大值和最小值之间的范围/差异,另一种使用标准偏差 - 他们希望答案正确到百分之一.我要用哪一个?这太令人困惑了.
我打开了一个.fits图片:
scaled_flat1 = pyfits.open('scaled_flat1.fit')
scaled_flat1a = scaled_flat1[0].data
Run Code Online (Sandbox Code Playgroud)
当我打印它的形状时:
print scaled_flat1a.shape
Run Code Online (Sandbox Code Playgroud)
我得到以下内容:
(1, 1, 510, 765)
Run Code Online (Sandbox Code Playgroud)
我希望它阅读:
(510,765)
Run Code Online (Sandbox Code Playgroud)
我怎么摆脱之前的两个呢?
这是我从底部提供的函数中得到的错误:
'latex' is not recognized as an internal or external command,
operable program or batch file.
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\python27\lib\lib-tk\Tkinter.py", line 1486, in __call__
return self.func(*args)
File "C:\python27\lib\site-packages\matplotlib\backends\backend_tkagg.py", lin
e 278, in resize
self.show()
File "C:\python27\lib\site-packages\matplotlib\backends\backend_tkagg.py", lin
e 349, in draw
FigureCanvasAgg.draw(self)
File "C:\python27\lib\site-packages\matplotlib\backends\backend_agg.py", line
469, in draw
self.figure.draw(self.renderer)
File "C:\python27\lib\site-packages\matplotlib\artist.py", line 59, in draw_wr
apper
draw(artist, renderer, *args, **kwargs)
File "C:\python27\lib\site-packages\matplotlib\figure.py", line 1079, in draw
func(*args)
File "C:\python27\lib\site-packages\matplotlib\artist.py", line 59, in draw_wr …Run Code Online (Sandbox Code Playgroud) 我安装了最新版本的PyCharm(2017.1)。一切正常,除非我尝试在同一窗口中打开两个项目。我打后得到这个弹出OK的Open Project对话(它给你的选项,Open in a new window或Open in current window)。
我尝试了此处提到的修复程序(无论如何,这确实很愚蠢)。也尝试将*.iml文件扔到./idea目录中,但这给了我:
5/4/17
5:11 PM Load Settings
Cannot load settings from file '/home/brandon/Downloads/chalice/.idea/chalice.iml': content truncated
File content will be recreated
Run Code Online (Sandbox Code Playgroud)
同样,我要打开哪个项目都没有关系,所以请替换chalice为*。打开单个*.py文件很好,但是我无法打开项目。
任何人都有解决方案,以便我可以重新开始编写Python?:D
编辑:所以现在我已经下载了最新版本的PyCharm并重新安装了它。现在,如果没有这个弹出窗口,我什至无法创建新项目。
这里发生了什么 ???
我有一个 10mX10m“像素”的 200X200 网格/数组(即 40,000 个值),其值表示该点土地的平均海拔。
整个网格有巨大的连接区域,其中海拔值为 0 米,因为它们代表实际的海洋。
问题:有没有一种快速算法可以获取大致的土地面积?我知道我可以乘以 200^2*10^2 来获得面积的粗略近似值,但有些值变化很大。
我想我知道一种相当昂贵的方法,即对顶点位于高程的所有三角形求和。但有没有更快/更简单的方法呢?
以下是我在实施Левенштейн时使用"矩阵记忆"到目前为止一起入侵的内容.我正在尝试将Haskell用于几乎所有事情,以便我真正学习它.我还没有真正掌握的概念包括monad变形金刚,州monad(工作)和镜头.
import Data.Matrix
import Control.Monad.State
import Control.Applicative
type RecState = Int
-- Set up the first row
setLeftCol :: String -> Matrix Int -> Maybe (Matrix Int)
setLeftCol str mat = let strLength = length str + 1
in foldr helper (Just mat) [1..strLength]
where
helper :: Int -> Maybe (Matrix Int) -> Maybe (Matrix Int)
helper value matrixMon = (\m -> safeSet (value-1) (value,1) m) =<< matrixMon
-- Encapsulate a transposition in a Maybe context
transposeM :: Matrix a …Run Code Online (Sandbox Code Playgroud) 假设我有一个Numpy数组,例如
rand = np.random.randn(6, 6)
Run Code Online (Sandbox Code Playgroud)
我需要数组中的中心四个值,因为它的轴的长度是偶数。如果它是奇数,例如5乘5,则将只有一个中心值。检索这四个条目的最简单/最快/最简单的方法是什么?我可以通过索引非常粗略地获取它们,但是我正在寻找一种比调用一堆函数和执行一堆计算更快的方法。
例如,考虑以下内容:
array([[ 0.25659355, -0.75456113, 0.39467396, 0.50805361],
[-0.77218172, 1.00016061, -0.70389486, 1.67632146],
[-0.41106158, -0.63757421, 1.70390504, -0.79073362],
[-0.2016959 , 0.55316318, -1.55280823, 0.45740193]])
Run Code Online (Sandbox Code Playgroud)
我想要以下内容:
array([[1.00016061, -0.70389486],
[-0.63757421, 1.70390504]])
Run Code Online (Sandbox Code Playgroud)
但是,不仅是4×4阵列-如果是偶数,我也希望像上面那样集中四个元素。
我找到了这个答案, which seems to be somewhat related to this question, but I'm wondering if it's possible to generate the coordinates one by one without the additional ~22% (1 - pi / 4) loss of comparing each point to the radius of the circle (by computing the distance between the circle's center and that point).
到目前为止,我在 Python 中有以下函数。我知道通过高斯圆问题我最终会得到坐标的数量,但我也想一一生成这些点。
from typing import Iterable
from math import sqrt, floor
def circCoord(sigma: float =1.0, centroid: tuple =(0, 0)) -> …Run Code Online (Sandbox Code Playgroud) 我不确定以前是否曾经问过这个问题,如果有问题我会道歉,但我有以下简单的代码行:
for s in lst_times:
#print(s)
f.write( str() + " " + str(s)+ " " + "\n" )
Run Code Online (Sandbox Code Playgroud)
在这个循环中,有没有办法在列表lst_times中使用s的实际整数值而不是索引为s的元素?
感谢您的时间,
我希望能够通过Python中的整数,浮点数和其他相等长度的列表来划分整个列表,因此我编写了以下小脚本.
class divlist(list):
def __init__(self, *args, **kwrgs):
super(divlist, self).__init__(*args, **kwrgs)
self.__cont_ = args[0]
self.__len_ = len(args[0])
def __floordiv__(self, other):
""" Adds the ability to floor divide list's indices """
if (isinstance(other, int) or isinstance(other, float)):
return [self.__cont_[i] // other \
for i in xrange(self.__len_)]
elif (isinstance(other, list)):
return [self.__cont_[i] // other[i] \
for i in xrange(self.__len_)]
else:
raise ValueError('Must divide by list, int or float')
Run Code Online (Sandbox Code Playgroud)
我的问题:我怎么能以更简单的方式写这个?我真的需要行self.__cont_和self.__len_?我正在查看列表的"魔法"方法,我找不到一个容易掌握这些信息的方法.
调用这个简单类的一个例子:
>>> X = divlist([1,2,3,4])
[1, 2, 3, 4]
>>> …Run Code Online (Sandbox Code Playgroud)