我正在使用深度神经网络模型(在 中实现keras)进行预测。像这样的东西:
def make_model():
model = Sequential()
model.add(Conv2D(20,(5,5), activation = "relu"))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Flatten())
model.add(Dense(20, activation = "relu"))
model.add(Lambda(lambda x: tf.expand_dims(x, axis=1)))
model.add(SimpleRNN(50, activation="relu"))
model.add(Dense(1, activation="sigmoid"))
model.compile(loss = "binary_crossentropy", optimizer = adagrad, metrics = ["accuracy"])
return model
model = make_model()
model.fit(x_train, y_train, validation_data = (x_validation,y_validation), epochs = 25, batch_size = 25, verbose = 1)
##Prediciton:
prediction = model.predict_classes(x)
probabilities = model.predict_proba(x) #I assume these are the probabilities of class being predictied
Run Code Online (Sandbox Code Playgroud)
我的问题是分类(二进制)问题。我希望计算其中每一个的置信度得分,prediction即我想知道 - 我的模型是 99% 确定它是“0”还是 58% …
machine-learning uncertainty confidence-interval keras tensorflow
我收到错误:ValueError: Input 0 is incompatible with layer lstm_1: expected ndim=3, found ndim=2使用以下代码:
def make_model():
model = Sequential()
model.add(Conv2D(20,(5,5), input_shape = (24,48,30), activation = "relu", strides = 1, padding = "valid"))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Conv2D(50, (5,5), use_bias = 50))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Flatten())
model.add(Dense(20, activation = "relu"))
model.add(LSTM(50, activation="relu", return_sequences=True))
return model
Run Code Online (Sandbox Code Playgroud)
我的输入是 30 个大小为 24*48 的矩阵。
我需要添加各列的行值并将其存储在相同(或新)数据框中。例如:数据框看起来像这样:
id col1 col2 col3 col4 ... col50
1 1 12 3 44 0
1 7 0 7 2 10
1 2 3 0 4 9
3 9 0 1 0 0
3 1 1 11 1 0
Run Code Online (Sandbox Code Playgroud)
预期值应该是:
id col1 col2 col3 col4... col50
1 10 15 10 46 19
3 10 1 12 1 0
Run Code Online (Sandbox Code Playgroud)
如果我使用tmp2 = tmp2.iloc[:,1:50].sum(),它会改变数据框的尺寸。
我有一个创建.csv文件的 python 脚本。
当我尝试通过以下方式下载脚本中的文件Vectors.csv(由代码创建的文件)时
df.to_csv("Vectors.csv", sep=",", index=False)
files.download("Vectors.csv")
Run Code Online (Sandbox Code Playgroud)
我明白了
Traceback (most recent call last):
File "/content/gdrive/My Drive/Deep/makeVectors.py", line 52, in <module>
files.download("Vectors.csv")
File "/usr/local/lib/python3.6/dist-packages/google/colab/files.py", line 178, in download
'name': _os.path.basename(filename),
File "/usr/local/lib/python3.6/dist-packages/google/colab/output/_js.py", line 35, in eval_js
kernel = _ipython.get_kernel()
File "/usr/local/lib/python3.6/dist-packages/google/colab/_ipython.py", line 28, in get_kernel
return get_ipython().kernel
AttributeError: 'NoneType' object has no attribute 'kernel'
Run Code Online (Sandbox Code Playgroud)
然而,当我在 Colab 单元格中键入相同的命令时,它工作得很好。
浏览器:谷歌浏览器
keras ×2
dataframe ×1
keras-layer ×1
pandas ×1
python ×1
python-3.x ×1
tensorflow ×1
uncertainty ×1