theano.scan返回两个变量:values变量和更新变量.例如,
a = theano.shared(1)
values, updates = theano.scan(fn=lambda a:a+1, outputs_info=a, n_steps=10)
Run Code Online (Sandbox Code Playgroud)
但是,我注意到在我使用的大多数示例中,updates变量都是空的.似乎只有当我们theano.scan以某种方式编写函数时,我们才会获得更新.例如,
a = theano.shared(1)
values, updates = theano.scan(lambda: {a: a+1}, n_steps=10)
Run Code Online (Sandbox Code Playgroud)
有人可以向我解释为什么在第一个例子中更新是空的,但在第二个例子中,更新变量不为空?更一般地说,更新如何变量theano.scan起作用?谢谢.
我有一个数组。例如,
x = [1,2,3,4,5]
Run Code Online (Sandbox Code Playgroud)
我知道命令
x.delete_at(i)
Run Code Online (Sandbox Code Playgroud)
将从数组中删除索引i处的元素。但从我所读到的,它只能处理一个论点。
假设我有一个变量来存储我希望从x 中删除的索引。例如,
y = [0,2,3]
Run Code Online (Sandbox Code Playgroud)
我的问题:是否可以使用存储在要删除的索引中的另一个数组从数组中删除多个元素?
本质上,类似
x.delete_at(y)
Run Code Online (Sandbox Code Playgroud)
谢谢!:)
我正在使用Digital Ocean Droplet进行导轨应用.我成功地部署了第一个应用程序,但现在面临着尝试部署第二个应用程序的问题.我使用unicorn作为app服务器,nginx作为web服务器.操作系统是Ubuntu 14.04
我已经在stackexchange网站上阅读了很多帖子,也在博客等上阅读过,但它们都不符合我的立场.我认为问题出在应用程序和系统文件夹/文件/配置结构上.我更加谨慎地改变系统配置文件.
在网络上的大多数例子中,每个人都在讨论unicorn.rb,
rails_root/config/但我没有.相反,我的unicorn.conf里面有相同的内容/etc.
还有一个侦听第一个应用程序的套接字文件,我尝试了两个为我的第二个应用程序创建第二个 - 但它失败了.
我知道,我必须为第二个应用程序创建另一个独角兽配置,并且还必须做一些应该通过创建第二个套接字的结果.
但缺乏对系统管理的了解和理解使我陷入困境.
任何人都可以指导我这个问题吗?
如果需要,我可以提供更多文件.
第一个应用程序(路径/etc/sites-available/first_app)的nginx配置文件.
upstream app_server {
server unix:/var/run/unicorn.sock fail_timeout=0;
}
server {
listen 80;
root /home/rails/myfirstapp/public;
server_name www.myfirstapp.com;
index index.htm index.html index.php index.asp index.aspx index.cgi index.pl index.jsp;
location / {
try_files $uri/index.html $uri.html $uri @app;
}
location ~* ^.+\.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|mp3|flv|mpeg|avi)$ {
try_files $uri @app;
}
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
}
server {
listen 80; …Run Code Online (Sandbox Code Playgroud) 我想程序流中有一个逻辑错误,返回NoMethodError
首先,一段导致错误的代码.
<input id="#identity" type="number" name="journal[identity]" value="<%= @journal.identity unless @journal.identity.nil? %>" />
#Error Text
NoMethodError at /profile
undefined method `identity' for nil:NilClass
file: journal_form.erb location: block in singleton class line: 2
Run Code Online (Sandbox Code Playgroud)
输入标记内的代码是错误文本中描述的确切代码段.
我的程序流程就是这样.
/profile页面1还可以.用户可以毫无问题地登录和注销.对于第二步,代码就是这样
#profile.erb
<% if session[:user].role == 1 %>
<%= erb :assign_doctor %>
<% elsif session[:user].role == 2 %>
<%= erb :journal_form %>
<% elsif session[:user].role == 3 %>
<pre>
Silence!
</pre>
<% elsif session[:user].role == 4 %>
<%= erb :doctor_screen …Run Code Online (Sandbox Code Playgroud) 我正在尝试在postgres上为4个表执行连接查询.
表名:
scenarios_scenariopayments_invoicepayments_paymentpayments_action(所有这些奇怪的名字都是由django生成的 - )))
关系:
scenarios_scenario[有很多] payments_actionspayments_action [有一个] payments_invoice payments_action [有一个] payments_payment 下面是一个工作查询,
SELECT payments_invoice.*,
(payments_payment.to_be_paid - payments_payment.paid) as remaining, \
payments_action.identificator
FROM payments_invoice
JOIN payments_payment
ON payments_invoice.action_id = payments_payment.action_id
AND payments_payment.full_payment=2
JOIN payments_action
ON payments_invoice.action_id = payments_action.id
AND payments_action.identificator = %s
Run Code Online (Sandbox Code Playgroud)
我只是想从另一个表中检索一个相关的字段,并写了另一个查询
SELECT
scenarios_scenario.title, payments_invoice.*, \
(payments_payment.to_be_paid - payments_payment.paid) as remaining, \
payments_action.identificator, payments_action.scenario_id
FROM payments_invoice
JOIN scenarios_scenario
ON scenarios_scenario.id = payments_action.scenario_id
JOIN payments_payment
ON payments_invoice.action_id = payments_payment.action_id
AND payments_payment.full_payment=2
JOIN …Run Code Online (Sandbox Code Playgroud) 这是我的代码
class TestLogin < MiniTest::Test
def setup
@driver=Selenium::WebDriver.for :firefox
@driver.manage.window.maximize
@driver.navigate.to "http://google.com"
end
def test_case1
puts "testcase1"
end
def test_case2
puts "testcase2"
end
end
Run Code Online (Sandbox Code Playgroud)
我只想在开始时为两个测试用例运行一次 setup 方法。
我正在尝试为cms网站建立一个管理员后端.
这是我的应用程序的结构
??? app.rb
??? Gemfile
??? models
? ??? models.rb
??? routes
? ??? routes.rb
??? views
??? categories.erb
??? # ... other view files
Run Code Online (Sandbox Code Playgroud)
app.rb
require 'sinatra'
require 'data_mapper'
require 'dm-core'
require 'dm-migrations'
require 'digest'
enable :sessions
DataMapper.setup(:default, 'mysql://username:password@localhost/database')
require './models/models.rb'
require './routes/routes.rb'
DataMapper.finalize
Run Code Online (Sandbox Code Playgroud)
models.rb
class Category
include DataMapper::Resource
property :id, Serial
property :name, String
has n, :posts
end
# other model definitons
Run Code Online (Sandbox Code Playgroud)
我在routes.rb中定义了categories一条路线
...
get '/categories' do
@categories = Category.all
erb :categories
end …Run Code Online (Sandbox Code Playgroud) 我正在寻找列表中的单词以不同的组合连接在一起,但它只返回单个单词结果.我正在寻找像'whywho''whatwhywhen''howwhywhatwho'等字符串.
import random, sys
words = ['why', 'who', 'what', 'why', 'when', 'how']
for i in range(100):
print ''.join(random.choice(words[:randint(1, 4)]))
Run Code Online (Sandbox Code Playgroud) {
"receiver_uid":[
"58a43a3e3fbbf3.61108490",
"58a43be07a3bc3.90311110",
"58da53ab5ce8d6.84754819"
]
}
Run Code Online (Sandbox Code Playgroud)
这是我想转换为数组的值。我知道这是一个非常简单的问题,但请有人帮助我吗?