我在CentOS 6.5上使用Apache 2.2.15.我正在尝试使用mod_wsgi设置Django应用程序.我正在使用虚拟环境,并且配置了mod_wsgi --with-python=/path/to/virtualenv/bin/python3.4.
我已将此添加到我的httpd.conf:
WSGIPythonPath /srv/myproject:/path/to/virtualenv/lib/python3.4/site-packages
WSGIPythonHome /path/to/virtualenv
<VirtualHost *:80>
WSGIScriptAlias / /srv/myproject/myproject/wsgi.py
...
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
在wsgi.py,我补充说
sys.path.insert(1, "/path/to/virtualenv/lib/python3.4/site-packages")
Run Code Online (Sandbox Code Playgroud)
问题是,当我尝试在浏览器中打开应用程序时,它会无限期地加载.这是Apache错误日志:
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
[Mon Jun 30 17:37:28 2014] [notice] child pid 19370 exit signal Aborted (6)
[Mon Jun 30 17:37:28 2014] [notice] child pid 19371 exit signal Aborted (6)
...
[Mon Jun 30 17:37:28 2014] [notice] child pid 19377 exit signal Aborted (6) …Run Code Online (Sandbox Code Playgroud) 我有一个使用自定义身份验证后端 ( CoSign )运行 Django 1.6 的站点。身份验证有效,但要注销,我需要删除 cookie。
这是注销前的 cookie,使用 Firebug:
这是我的注销视图:
from django.contrib.auth.views import logout as django_logout
def logout(request):
if request.user.is_authenticated():
response = django_logout(request,
next_page=reverse("logout-confirmation"))
response.delete_cookie('cookie_name',
domain="cookie_domain")
return response
else:
messages.add_message(request,
messages.ERROR,
"You can't log out if you aren't logged "
"in first!")
return HttpResponseRedirect(reverse("frontpage"))
Run Code Online (Sandbox Code Playgroud)
我的代码中的 cookie_name 和 cookie_domain 与 cookie 的实际名称和域匹配。
以下是注销视图的响应标头:
Connection: "close"
Content-Length: "0"
Set-Cookie: "{{ cookie_name }}=; Domain={{ cookie_domain }}; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/sessionid=25lysb3tzhozv464mrgg08uqz100ur39; expires=Mon, 15-Sep-2014 19:07:22 …Run Code Online (Sandbox Code Playgroud) 我正在从 numpy 数组列表中创建几个 numpy 数组,如下所示:
seq_length = 1500
seq_diff = 200 # difference between start of two sequences
# x and y are 2D numpy arrays
x_seqs = [x[i:i+seq_length,:] for i in range(0, seq_diff*(len(x) // seq_diff), seq_diff)]
y_seqs = [y[i:i+seq_length,:] for i in range(0, seq_diff*(len(y) // seq_diff), seq_diff)]
boundary1 = int(0.7 * len(x_seqs)) # 70% is training set
boundary2 = int(0.85 * len(x_seqs)) # 15% validation, 15% test
x_train = np.array(x_seqs[:boundary1])
y_train = np.array(y_seqs[:boundary1])
x_valid = np.array(x_seqs[boundary1:boundary2])
y_valid = np.array(y_seqs[boundary1:boundary2]) …Run Code Online (Sandbox Code Playgroud) 我一直在查看有关多个索引的Haystack文档,但我无法弄清楚如何使用它们.
这个例子中的主要模型是Proposal.我希望有两个搜索索引可以返回提案列表:一个只搜索提案本身,另一个搜索提案及其注释.我这样设置search_indexes.py:
class ProposalIndexBase(indexes.SearchIndex, indexes.Indexable)
title = indexes.CharField(model_attr="title", boost=1.1)
text = indexes.NgramField(document=True, use_template=True)
date = indexes.DateTimeField(model_attr='createdAt')
def get_model(self):
return Proposal
class ProposalIndex(ProposalIndexBase):
comments = indexes.MultiValueField()
def prepare_comments(self, object):
return [comment.text for comment in object.comments.all()]
class SimilarProposalIndex(ProposalIndexBase):
pass
Run Code Online (Sandbox Code Playgroud)
这是我的搜索views.py:
def search(request):
if request.method == "GET":
if "q" in request.GET:
query = str(request.GET.get("q"))
results = SearchQuerySet().all().filter(content=query)
return render(request, "search/search.html", {"results": results})
Run Code Online (Sandbox Code Playgroud)
如何设置从特定索引获取SearchQuerySet的单独视图?
我正在使用传统的序列到序列框架在TensorFlow 1.0.1中构建编码器 - 解码器模型.当我在编码器和解码器中有一层LSTM时,一切正常.但是,当我尝试使用包裹在a中的> 1层LSTM时MultiRNNCell,我在调用时出错tf.contrib.legacy_seq2seq.rnn_decoder.
完整的错误是在这篇文章的最后,但简而言之,它是由一条线引起的
(c_prev, m_prev) = state
Run Code Online (Sandbox Code Playgroud)
在投掷的TensorFlow中TypeError: 'Tensor' object is not iterable..我对此感到困惑,因为我传递的初始状态rnn_decoder确实是一个应该是的元组.据我所知,使用1层或> 1层的唯一区别是后者涉及使用MultiRNNCell.使用它时是否有一些我应该知道的API怪癖?
这是我的代码(基于此 GitHub仓库中的示例).道歉的长度; 这是我能做到的最小化,同时仍然是完整和可验证的.
import tensorflow as tf
import tensorflow.contrib.legacy_seq2seq as seq2seq
import tensorflow.contrib.rnn as rnn
seq_len = 50
input_dim = 300
output_dim = 12
num_layers = 2
hidden_units = 100
sess = tf.Session()
encoder_inputs = []
decoder_inputs = []
for i in range(seq_len):
encoder_inputs.append(tf.placeholder(tf.float32, shape=(None, input_dim),
name="encoder_{0}".format(i)))
for i in range(seq_len + …Run Code Online (Sandbox Code Playgroud)