我想将 K-Fold 交叉验证应用于我的神经网络模型,如下所示:
from sklearn.model_selection import StratifiedKFold
from numpy import *
from keras.wrappers.scikit_learn import KerasClassifier
from sklearn.model_selection import cross_val_score
import numpy
X = df.iloc[:,0:10165]
X = X.to_numpy()
X = X.reshape([X.shape[0], X.shape[1],1])
X_train_1 = X[:,0:10080,:]
X_train_2 = X[:,10080:10165,:].reshape(921,85)
Y = df.iloc[:,10168:10170]
Y = Y.to_numpy()
def my_model():
inputs_1 = keras.Input(shape=(10080,1))
layer1 = Conv1D(64,14)(inputs_1)
layer2 = layers.MaxPool1D(5)(layer1)
layer3 = Conv1D(64, 14)(layer2)
layer4 = layers.GlobalMaxPooling1D()(layer3)
inputs_2 = keras.Input(shape=(85,))
layer5 = layers.concatenate([layer4, inputs_2])
layer6 = Dense(128, activation='relu')(layer5)
layer7 = Dense(2, activation='softmax')(layer6)
model_2 = keras.models.Model(inputs = …Run Code Online (Sandbox Code Playgroud) 我正在使用的代码接收一个 .pdf 文件,并输出一个 .txt 文件。我的问题是,如何创建一个循环(可能是 for 循环),该循环在以“.pdf”结尾的文件夹中的所有文件上一遍又一遍地运行代码?此外,如何在每次循环运行时更改输出,以便每次都可以编写一个与输入文件同名的新文件(即 1_pet.pdf > 1_pet.txt、2_pet.pdf > 2_pet.pdf)。 txt等)
这是到目前为止的代码:
path="2_pet.pdf"
content = getPDFContent(path)
encoded = content.encode("utf-8")
text_file = open("Output.txt", "w")
text_file.write(encoded)
text_file.close()
Run Code Online (Sandbox Code Playgroud) 我已经PostgreSQL在 macOS 上通过 brew安装了:
brew install postgresql
Run Code Online (Sandbox Code Playgroud)
尝试了这些命令,都失败了:
错误:
brew install postgresql
Run Code Online (Sandbox Code Playgroud)
此外,将其设置为 shell 然后重新加载:
...
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Users/user0/.pyenv/versions/3.8.0/include/python3.8 -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/adapter_qstring.c -o build/temp.macosx-10.14-x86_64-3.8/psycopg/adapter_qstring.o
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Users/user0/.pyenv/versions/3.8.0/include/python3.8 -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/microprotocols.c -o build/temp.macosx-10.14-x86_64-3.8/psycopg/microprotocols.o
clang -Wno-unused-result …Run Code Online (Sandbox Code Playgroud)