我最近开始使用tensorflow,所以我仍然在努力学习基础知识.
我想创建简单的seq2seq预测.
我设法评估模型性能并优化权重.我一直在努力的是如何用训练有素的模型进行预测.
model_outputs, states = seq2seq.basic_rnn_seq2seq(encoder_inputs,
decoder_inputs,
rnn_cell.BasicLSTMCell(data_point_dim, state_is_tuple=True))
Run Code Online (Sandbox Code Playgroud)
为了生成model_outputs,我需要模型的输入和输出值,这有利于评估,但在预测中我只有输入值.我猜我需要对状态做些什么,但我不确定如何将它们转换为浮点序列.
完整代码可在此处 https://gist.github.com/anonymous/be405097927758acca158666854600a2
我正在使用JSCH进行文件上传sftp.在当前状态下,每个线程在需要时打开和关闭连接.
如果可以使用与JSCH的连接池以避免由大量连接打开和关闭引起的开销?
这是从线程内部调用的函数示例
public static void file_upload(String filename) throws IOException {
JSch jsch = new JSch();
Session session = null;
try {
session = jsch.getSession("user", "server_name", 22);
session.setConfig("StrictHostKeyChecking", "no");
session.setPassword("super_secre_password");
session.connect();
Channel channel = session.openChannel("sftp");
channel.connect();
ChannelSftp sftpChannel = (ChannelSftp) channel;
FileInputStream inputSrr = new FileInputStream(filename);
try {
sftpChannel.put(inputSrr, "/var/temp/"+filename);
} catch (SftpException e) {
e.printStackTrace();
} finally {
if (inputSrr != null) {
inputSrr.close();
}
}
sftpChannel.exit();
session.disconnect();
} catch (JSchException e) {
e.printStackTrace();
} catch (SftpException e) { …
Run Code Online (Sandbox Code Playgroud) 我正在努力创建单元测试功能,负责上传从页面上的表单收到的图片.
主要问题是我无法弄清楚如何将图片添加到虚拟请求的发布参数,并因此将其传递给函数.
这是我试图测试的代码.
谢谢
@view_config(route_name='profile_pic')
def profilePictureUpload(request):
if 'form.submitted' in request.params:
#max picture size is 700kb
form = Form(request, schema=PictureUpload)
if request.method == 'POST' and form.validate():
upload_directory = 'filesystem_path'
upload = request.POST.get('profile')
saved_file = str(upload_directory) + str(upload.filename)
perm_file = open(saved_file, 'wb')
shutil.copyfileobj(upload.file, perm_file)
upload.file.close()
perm_file.close()
else:
log.info(form.errors)
redirect_url = route_url('profile', request)
return HTTPFound(location=redirect_url)
Run Code Online (Sandbox Code Playgroud) 我在 Apache 重定向方面遇到了一些问题。虽然波纹管规则适用于网站上的任何页面,但 mydomain.com 将被重定向到 mydomain.com//,这会忽略尾部斜杠删除规则。
使用多个规则是否有效,或者我应该尝试将它们组合或以某种方式将它们链接在一起以避免单个 url 的多次重定向?
谢谢
#Turn on options for url rewriting
Options +FollowSymlinks
RewriteEngine on
#lovercase all urls
RewriteMap lc int:tolower
RewriteCond %{REQUEST_URI} [A-Z]
RewriteCond %{REQUEST_URI} ^/fonts/.*
RewriteCond %{REQUEST_URI} ^/css/.*
RewriteCond %{REQUEST_URI} ^/js/.*
RewriteRule (.*) ${lc:$1} [R=301,L]
#redirect all requests made to http:// to http://www.
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]
#removes trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} !^\.localhost$ [NC]
RewriteRule ^(.+)/$ http://%{HTTP_HOST}$1 [R=301,L]
Run Code Online (Sandbox Code Playgroud) 我刚刚完成了mod_wsgi的安装,但是我在启动Pyramid应用程序时遇到了问题.
我在CentOS 5.8上使用python 2.7,Apache 2.2.3,mod_wsgi 3.4
这是我的httpd.config文件
WSGISocketPrefix run/wsgi
<VirtualHost *:80>
ServerName myapp.domain.com
ServerAlias myapp
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
WSGIDaemonProcess pyramid user=apache group=apache processes=1 threads=4 \
python-path=/var/wsgi_sites/site-packages
WSGIScriptAlias / /var/wsgi_sites/myapp/apache.wsgi
<Directory /var/wsgi_sites/myapp>
WSGIProcessGroup pyramid
Order allow,deny
Allow from all
</Directory>
LogLevel debug
ErrorLog /var/log/httpd/myapp_error
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
我给了Apache所有的site-package,python-eggs和myapp文件夹.
我用来创建WSGI应用程序appache.wsgi的模块包含以下代码
import os
os.environ['PYTHON_EGG_CACHE'] = '/var/wsgi_sites/python-eggs'
from pyramid.paster import get_app
application = get_app('/var/wsgi_sites/myapp/development.ini','main')
Run Code Online (Sandbox Code Playgroud)
当我重新启动Apache并尝试访问应用程序时,我收到以下错误
mod_wsgi (pid=14842, process='pyramid', application=''): Loading WSGI script '/var/wsgi_sites/myapp/apache.wsgi'.
mod_wsgi (pid=14842): Target WSGI script '/var/wsgi_sites/myapp/apache.wsgi' cannot be loaded as Python module. …
Run Code Online (Sandbox Code Playgroud) python ×3
apache ×2
pyramid ×2
java ×1
jsch ×1
lstm ×1
mod-rewrite ×1
mod-wsgi ×1
python-2.7 ×1
sftp ×1
tensorflow ×1
unit-testing ×1