我正在尝试按照此链接构建深度自动编码器,但出现此错误:
值错误:输入 0 与层密集_6 不兼容:输入形状的预期轴 -1 具有值 128 但得到形状(无,32)
编码:
input_img = Input(shape=(784,))
encoded = Dense(128, activation='relu')(input_img)
encoded = Dense(64, activation='relu')(encoded)
encoded = Dense(32, activation='relu')(encoded)
decoded = Dense(64, activation='relu')(encoded)
decoded = Dense(128, activation='relu')(decoded) #decode.shape = (?,128)
decoded = Dense(784, activation='relu')(decoded)
autoencoder = Model(input_img, decoded)
encoder = Model(input_img, encoded)
encoded_input = Input(shape=(encoding_dim,))
decoder_layer = autoencoder.layers[-1]
decoder = Model(encoded_input, decoder_layer(encoded_input)) #ERROR HERE
...
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
Traceback (most recent call last):
File "autoencoder_deep.py", line 37, in <module>
decoder = Model(encoded_input, decoder_layer(encoded_input))
File …Run Code Online (Sandbox Code Playgroud) 到目前为止,我有一些不应运行的单元测试,是否可以跳过它们?除了在要运行的程序上使用fdescribe之外。
当我以编程方式将画外音焦点移至标签时,不会读出标签的提示。我该如何解决这个问题?仅读出可访问性标签。
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, self.label)
我有一个 UITableView,其中每个 UITableViewCell 有 2 个 UILabels:1 个标题和 1 个内容。标头的 AccessibilityTrait 设置为“标头”。使用 Accessibility Inspector 检查模拟器屏幕时,我能够正确地看到特征集。但是在实际设备上,当我将转子切换到“标题”时,它只找到导航栏标题,而在 UITableViewCells 中找不到标题。
在构建卷积神经网络时,如何确定每个卷积层使用的滤波器数量。我知道过滤器的数量没有硬性规定,但是根据您阅读的经验/论文等,是否有关于使用的过滤器数量的直觉/观察?
例如(我只是将其作为示例):
随着网络的深入,使用更多/更少的过滤器。
使用大/小内核大小的大/小过滤器
我正在使用nodejs v8.8.1和angular-cli v6.0.8,我收到了这个错误:
您正在运行Node.js的v8.8.1版本,Angular CLI v6不支持该版本.支持的官方Node.js版本是8.9或更高版本.
如果我要安装不同版本的angular-cli,我该如何检查nodejs v8.8.1支持哪个版本?因为我必须使用nodejs v8.8.1,所以我无法做到这一点.
我正在使用Angular5,并且有一个字段列表,每个字段都有一个名称和FormControl。我尝试使用此代码将控件动态添加到组中,但出现错误。
const formControlFields = [
{name: 'field1',control: [null, []] as FormControl},
{name: 'field2',control: [null, []] as FormControl}
];
const formGroup: FormGroup = new FormGroup({});
formControlFields.forEach( f => formGroup.addControl(f.name,f.control));
this.form = new FormGroup({groups:formGroup});
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
错误TypeError:control.setParent不是函数
Run Code Online (Sandbox Code Playgroud)at FormGroup.registerControl (forms.js:4352) at FormGroup.addControl (forms.js:4372) at eval (trade-search.component.ts:142)
我正在使用keras的预训练模型,调用ResNet50(weights ='imagenet')时出现错误。我在Flask服务器中有以下代码:
def getVGG16Prediction(img_path):
model = VGG16(weights='imagenet', include_top=True)
img = image.load_img(img_path, target_size=(224, 224))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)
pred = model.predict(x)
return sort(decode_predictions(pred, top=3)[0])
def getResNet50Prediction(img_path):
model = ResNet50(weights='imagenet') #ERROR HERE
img = image.load_img(img_path, target_size=(224, 224))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)
preds = model.predict(x)
return decode_predictions(preds, top=3)[0]
Run Code Online (Sandbox Code Playgroud)
在main中调用时,它工作正常
if __name__ == "__main__":
STATIC_PATH = os.getcwd()+"/static"
print(getVGG16Prediction(STATIC_PATH+"/18.jpg"))
print(getResNet50Prediction(STATIC_PATH+"/18.jpg"))
Run Code Online (Sandbox Code Playgroud)
但是,当我从烧瓶POST函数调用它时,ValueError上升:
@app.route("/uploadMultipleImages", methods=["POST"])
def uploadMultipleImages():
uploaded_files = request.files.getlist("file[]")
weight = request.form.get("weight") …Run Code Online (Sandbox Code Playgroud) 我想在图例中同时显示颜色和标记。颜色代表一件事,标记代表另一件事。它看起来应该像附加的图像。这是我目前的代码:
x = np.arange(20)
y = np.sin(x)
fig, ax = plt.subplots()
line1 = ax.scatter(x[:10],y[:10],20, c="red", picker=True, marker='*')
line2 = ax.scatter(x[10:20],y[10:20],20, c="red", picker=True, marker='^')
ia = lambda i: plt.annotate("Annotate {}".format(i), (x[i],y[i]), visible=False)
img_annotations = [ia(i) for i in range(len(x))]
def show_ROI(event):
for annot, line in zip([img_annotations[:10],img_annotations[10:20]], [line1, line2]):
if line.contains(event)[0]:
...
fig.canvas.draw_idle()
fig.canvas.mpl_connect('button_press_event', show_ROI)
plt.show()
Run Code Online (Sandbox Code Playgroud)
起初,我在 tensorflow 后端运行 keras,并且进度条很好。然后我安装了 Theano,并在切换回 tensorflow 之前尝试使用它一段时间。安装 Theano 后,出现在每个 epoch 的进度条只会在 epoch 完成后出现,所以在训练时,我看不到它的进度。
Epoch 1/50
21/21 [=============================] 10s - loss:0.6928 - loss_val: 0.6912
Run Code Online (Sandbox Code Playgroud)
我希望它在训练时显示进度,如下所示:
Epoch 1/50
21/21 [=====>.......................] 10s - loss:0.6928 - loss_val: 0.6912
Run Code Online (Sandbox Code Playgroud)
为什么安装theano后进度条格式变了,怎么改成显示进度?
我有一个表示为 numpy 数组的图像,其值为 0 和 255(范围内没有其他值)。将其转换为 0 和 1 数组的最佳方法是什么。
我正在尝试在我的项目中使用 Angular Material 并且导入了标签,但并非所有样式都在那里。
在我的 HTML 中:
<mat-form-field>
<input matInput [matDatepicker]="picker" placeholder="Choose a date">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker startView="year" [startAt]="startDate"></mat-datepicker>
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)
它应该显示:
但它显示:
我添加@import "~@angular/material/prebuilt-themes/indigo-pink.css";到 style.css 并且日历显示正常,但文本字段看起来仍然很糟糕。
我使用 fusion_matrix 模块来可视化类预测结果与实际值的比较。
val= ... #shape (3000,1,30) dtype float32
pred = ... #shape (3000,1,30) dtype float32
cnf_matrix = confusion_matrix(val, pred) #ERROR HERE
Run Code Online (Sandbox Code Playgroud)
我收到这个错误:
回溯(最近一次调用最后一次):文件“vis.py”,第 757 行,在 cnf_matrix = fusion_matrix(y_test, y_pred) 文件“C:\Anaconda\envs\nn35\lib\site-packages\sklearn\metrics\classification. py”,第 240 行,confusion_matrix y_type, y_true, y_pred = _check_targets(y_true, y_pred) 文件“C:\Anaconda\envs\nn35\lib\site-packages\sklearn\metrics\classification.py”,第 89 行,在_check_targets raise ValueError("不支持{0}".format(y_type)) ValueError: 不支持未知
我做错了什么?
keras ×4
angular ×3
python ×2
tensorflow ×2
angular-cli ×1
angular6 ×1
flask ×1
ios ×1
keras-layer ×1
legend ×1
matplotlib ×1
node-modules ×1
node.js ×1
npm ×1
numpy ×1
scikit-learn ×1
swift ×1
theano ×1
voiceover ×1