我正在研究这个模型:
class Model(torch.nn.Module):
def __init__(self, sizes, config):
super(Model, self).__init__()
self.lstm = []
for i in range(len(sizes) - 2):
self.lstm.append(LSTM(sizes[i], sizes[i+1], num_layers=8))
self.lstm.append(torch.nn.Linear(sizes[-2], sizes[-1]).cuda())
self.lstm = torch.nn.ModuleList(self.lstm)
self.config_mel = config.mel_features
def forward(self, x):
# convert to log-domain
x = x.clip(min=1e-6).log10()
for layer in self.lstm[:-1]:
x, _ = layer(x)
x = torch.relu(x)
#x = torch_unpack_seq(x)[0]
x = self.lstm[-1](x)
mask = torch.sigmoid(x)
return mask
Run Code Online (Sandbox Code Playgroud)
进而:
model = Model(model_width, config)
model.cuda()
Run Code Online (Sandbox Code Playgroud)
但我收到此错误:
File "main.py", line 29, in <module>
Model.train(args)
File ".../src/model.py", line 57, in …Run Code Online (Sandbox Code Playgroud) 所以我正在研究 Dash Plotly。网页应该有一个文本框和一个按钮。这个想法是,当我写下图像名称然后选择按钮时,它将显示本地目录中的图像。
我试图将整个工作分为两部分。
首先,我有这段代码,它会显示您在文本框中写入的内容,然后单击按钮。代码:
# -*- coding: utf-8 -*-
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import os
from PIL import Image
import numpy as np
import plotly.express as px
os.chdir(os.path.dirname(os.path.abspath(__file__)))
external_stylesheets = ["https://codepen.io/chriddyp/pen/bWLwgP.css"]
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div(
[
html.I("Try typing the image name in input and observe it"),
html.Br(),
dcc.Input(id="input", type="text", placeholder=""),
html.Div(id="output"),
]
)
@app.callback(
Output("output", "children"),
Input("input", "value")
)
def update_output(input):
return u'Input {}'.format(input)
if …Run Code Online (Sandbox Code Playgroud)