在我将Windows 10升级到Creator更新后,每当我使用import numpy as np
from keras.models import Sequential
from keras.layers import Dense, LSTM, GlobalMaxPooling1D
D = np.random.rand(10, 6, 10)
model = Sequential()
model.add(LSTM(16, input_shape=(6, 10), return_sequences=True))
model.add(MaxPooling1D(pool_size=2, strides=1))
model.add(LSTM(10))
model.add(Dense(1))
model.compile(loss='binary_crossentropy', optimizer='sgd')
# print the summary to see how the dimension change after the layers are
# applied
print(model.summary())
# try a model with GlobalMaxPooling1D now
model = Sequential()
model.add(LSTM(16, input_shape=(6, 10), return_sequences=True))
model.add(GlobalMaxPooling1D())
model.add(Dense(1))
model.compile(loss='binary_crossentropy', optimizer='sgd')
print(model.summary())
输出一些中文字符时,我会在每个字符后面得到一个额外的空格。例如,如果我写cout
,我会得到&#34; 123中文&#34;。但是,如果我使用cout << "123中文" <<endl;
,一切正常,我得到&#34; 123中文&#34;。
我怀疑这是新控制台的错误,因为我的一个朋友有同样的问题。如果我切换到旧控制台,一切都可以正常工作。
如果我将输出重定向到文件或管道输出到另一个程序,我发现cout和printf的输出是相同的。现在我的问题是控制台如何区分printf
和cout
,并向我展示不同的结果?
修改
现在我要添加更多细节。
我正在测试的代码非常简单。
printf
测试:
cout
#include<iostream>
using namespace std;
int main(int argc, char** argv)
{
cout << "123中文" <<endl;
return 0;
}
测试:
printf
使用代码页936(GB2312)保存两个源文件,并使用Visual Studio 2017社区进行编译。我的Visual Studio和Windows都是中文的。
控制台的活动代码页是936。
我还写了一个简单的程序来查看我的程序输出的内容:
#include<iostream>
using namespace std;
int main(int argc, char** argv)
{
printf("123中文\n");
return 0;
}
我把它编译成hexecho.exe
然后在cmd中,#include<iostream>
using namespace std;
int main(int argc, char** argv)
{
cout << hex;
while (cin)
{
cout << cin.get() << endl;
}
return 0;
}
和printftest | hexecho
都给了我相同的输出:
couttest | hexecho
但是couttest和printftest确实在我的控制台中显示了不同的结果。
我也试过PowerShell,PowerShell也有这个问题。