我在一些函数中看到过这行代码
__traceback_hide__ = True
Run Code Online (Sandbox Code Playgroud)
它有什么作用?它似乎试图压制错误追溯.在什么情况下应该隐藏回溯?
model.fit(X_train, y_train, batch_size = batch_size,
nb_epoch = 4, validation_data = (X_test, y_test),
show_accuracy = True)
score = model.evaluate(X_test, y_test,
batch_size = batch_size, show_accuracy = True, verbose=0)
Run Code Online (Sandbox Code Playgroud)
给出标量输出,因此以下代码不起作用.
print("Test score", score[0])
print("Test accuracy:", score[1])
Run Code Online (Sandbox Code Playgroud)
我得到的输出是:训练20000个样本,验证5000个样本
Epoch 1/4
20000/20000 [==============================] - 352s - loss: 0.4515 - val_loss: 0.4232
Epoch 2/4
20000/20000 [==============================] - 381s - loss: 0.2592 - val_loss: 0.3723
Epoch 3/4
20000/20000 [==============================] - 374s - loss: 0.1513 - val_loss: 0.4329
Epoch 4/4
20000/20000 [==============================] - 380s - loss: 0.0838 - …Run Code Online (Sandbox Code Playgroud) 我想在我使用流浪汉射击的ubuntu vm上运行jupyter笔记本。
$ jupyter笔记本-无浏览器-端口8004 [我18:26:10.152 NotebookApp]从本地目录提供笔记本:/ home / vagrant / path / to / jupyter / notebook / directory [I 18:26:10.153 NotebookApp] 0个活动内核 [我18:26:10.154 NotebookApp] Jupyter Notebook运行于:http:// localhost:8004 / [I 18:26:10.154 NotebookApp]使用Control-C停止该服务器并关闭所有内核(两次跳过确认)。
Jupyter Notebook从localhost启动。但是要从主机访问笔记本,我需要在0.0.0.0中启动笔记本。如何绑定IP 0.0.0.0,使其路由到vm中的127.0.0.1?
我的主机是Windows,而vm是ubuntu 14.04.4
from keras.models import Sequential
from keras.layers.embeddings import Embedding
from theano import function
model = Sequential()
model.add(Embedding(max_features, 128, input_length = maxlen))
Run Code Online (Sandbox Code Playgroud)
我想从嵌入层获取输出.我在keras中阅读了源码,但没有找到任何合适的函数或属性.有人可以帮我这个吗?
我试图循环一个句子并使用正则表达式获取单词:
use regex::Regex; // 1.0.6
fn example() {
let re = Regex::new(r"\w+").unwrap();
let sample_text = "This is me me.";
for caps in re.captures_iter(&sample_text) {
if let Some(cap) = caps.get(0) {
let word = cap.to_string();
}
}
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误.
error[E0599]: no method named `to_string` found for type `regex::re_unicode::Match<'_>` in the current scope
--> src/lib.rs:8:28
|
8 | let word = cap.to_string();
| ^^^^^^^^^
|
= note: the method `to_string` exists but the following trait bounds were not satisfied:
`regex::re_unicode::Match<'_> : std::string::ToString` …Run Code Online (Sandbox Code Playgroud)