TL.DR. 是否有三维友好实施theano.tensor.nnet.neighbours.images2neibs?
我想使用一个接收nxnxn图像的神经网络对体积(NxNxN)进行体素分类,其中N> n.为了对体积中的每个体素进行分类,我必须遍历每个体素.对于每次迭代,我获得并传递邻域体素作为神经网络的输入.这只是一个滑动窗口操作,其操作是神经网络.
虽然我的神经网络在Theano中实现,但滑动窗口实现是python/numpy.由于这不是纯粹的Theano操作,因此分类需要永久(> 3小时)来对一个体积中的所有体素进行分类.对于2d滑动窗口操作,Theano有一个辅助方法theano.tensor.nnet.neighbours.images2neibs,是否有类似的三维图像实现?
编辑:nd滑动窗口现有numpy解决方案(1和2),都使用np.lib.stride_tricks.as_strided来提供"滑动窗口的视图",从而防止内存问题.在我的实现中,滑动窗口数组从numpy(Cython)传递到Python然后传递到Theano.为了提高性能,我可能不得不绕过Python.
我注意到我可以编写类似下面的函数来模拟类.我想知道这是否是最新的方式.任何评论赞赏.谢谢
function Apple(type) {
this.type = type;
this.color = "red";
this.getInfo = function () {
return this.color + ' ' + this.type + ' apple';
};
}
var apple = new Apple('testapple');
apple.color = 'blue';
console.log(apple.getInfo());
Run Code Online (Sandbox Code Playgroud) 我正在使用“ antd旋转木马”,但没有看到描述如何使用goTo(slideNumber, dontAnimate)方法的示例。
我试图在这个问题上使用带有箭头的react.js antd carousel的答案来使goTo方法对我有效,但没有帮助,我总是得到carousel ref作为null
import * as React from 'react';
import { createPortal } from 'react-dom';
import { Modal, Carousel } from 'antd'
export default class ImagePreviewCarousel extends React.Component<any, any> {
carousel = React.createRef();
componentDidMount() {
console.log(this.carousel);
}
render() {
const { url, imgList } = this.props;
const orderLayout = document.getElementById('order-layout');
const applicationLayout = document.getElementById('application');
return (
createPortal(<ImageViewer url={url} onClose={this.props.onClose} imgList={imgList} />, orderLayout || applicationLayout)
)
}
}
const …Run Code Online (Sandbox Code Playgroud) var x: { id: number, [x: string]: any }; // what does second property means?
x = { id: 1, fullname: "Zia" , 32: "Khan" }; // no errors in VS Code v0.9.1
Run Code Online (Sandbox Code Playgroud)
如果第二个属性是Array类型并且它的索引是string类型并且返回值是any类型,那么它如何接受索引是number类型并且value是string类型?
打字稿版本:1.6.2
Visual Studio 代码版本:0.9.1
我尝试使用简单的 Python 代码创建数据库,但它不起作用。
当我尝试创建数据库时,我在 python 和 MongoDb 中看不到我的数据库名称。
另外,当我在 MongoDb 中创建数据库时,我可以在 Python 中看到我的数据库名称。我的Python版本是3.6
你能帮我吗 ?
import pymongo
client = pymongo.MongoClient("mongodb://localhost:27017/")
mydb = client["mydatabase"]
print(client.list_database_names())
Run Code Online (Sandbox Code Playgroud) 我有元组中的假期列表:
holidays = [('Easter', ('Apr', 1), 0),
('Earth Day', ('Apr', 22), 0),
('Pearl Harbor Rememberance Day', ('Dec', 7), 0),
('Christmas Day', ('Dec', 25), 50),
('Groundhog Day', ('Feb', 2), 0)]
Run Code Online (Sandbox Code Playgroud)
以及对它们进行排序的功能:
def holiday1(holidays : [(str,(str,int),int)]) -> [(str,(str,int),int)]:
return sorted(holidays, key=lambda x:x[1])
Run Code Online (Sandbox Code Playgroud)
我按字母顺序按月分类,但我想按月份的位置对它们进行排序.(例如Jan = 1,Feb = 2等)
我已经为这几个月创建了一本字典:
months = {'Jan': 1, 'Feb': 2, 'Mar': 3, 'Apr': 4, 'May': 5, 'Jun': 6, 'Jul': 7, 'Aug': 8, 'Sep': 9, 'Oct': 10, 'Nov': 11, 'Dec': 12}
Run Code Online (Sandbox Code Playgroud)
我不确定如何使用dict'months'来排序元组列表,以便结果如下:
holidays = [('Groundhog Day', ('Feb', 2), 0), …Run Code Online (Sandbox Code Playgroud) 我正在创建一个类,我希望在该类的方法中调用用户定义的函数。我还想在类定义中定义函数。但是,当我调用该类时,收到错误消息name *whatever function* is not defined。
例如,这样的事情:
class ExampleClass():
def __init__(self, number):
self.number = number
def plus_2_times_4(x):
return(4*(x + 2))
def arithmetic(self):
return(plus_2_times_4(self.number))
Run Code Online (Sandbox Code Playgroud)
但是当我打电话时:
instance = ExampleClass(number = 4)
instance.arithmetic()
Run Code Online (Sandbox Code Playgroud)
我收到错误消息。
所以基本上我想在一个步骤 ( def plus_2_times_4) 中定义函数,并在另一个步骤 (d ef arithmetic...) 中定义方法时使用该函数。这可能吗?
非常感谢!
这是我之前的问题的后续问题(但是一个独立的问题)
\n\n我正在尝试在Mac上安装react和react-dom:
\n\nnpm install --save react react-dom\nRun Code Online (Sandbox Code Playgroud)\n\n但收到以下警告(路径名替换为...):
npm WARN saveError ENOENT: no such file or directory, open \'/Users/../Z/package.json\'\n/Users/.../Z\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac react@15.4.1 \n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac fbjs@0.8.8 \n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 core-js@1.2.7 \n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac isomorphic-fetch@2.2.1 \n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac node-fetch@1.6.3 \n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac encoding@0.1.12 \n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 iconv-lite@0.4.15 \n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 is-stream@1.1.0 \n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 whatwg-fetch@2.0.1 \n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac promise@7.1.1 \n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 asap@2.0.5 \n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 setimmediate@1.0.5 …Run Code Online (Sandbox Code Playgroud) 在下面的代码中:
#include <stdio.h>
int main(void) {
char* message = "Hello C Programmer!";
printf("%s", message);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我不完全理解为什么没有必要'*'在printf通话中添加to消息。我是在假设条件下message,因为它是一个指针char,双引号字符串中的第一个字母,将显示该地址的'H'。