基本上,我正在使用Keras训练LSTM模型,但是当我保存它时,它的大小需要100MB.但是,我的模型的目的是部署到Web服务器以作为API,我的Web服务器无法运行它,因为模型大小太大.在分析了我的模型中的所有参数之后,我发现我的模型有20,000,000参数但15,000,000参数未经训练,因为它们是字嵌入.有没有办法可以通过删除15,000,000参数来最小化模型的大小,但仍保留模型的性能?这是我的模型代码:
def LSTModel(input_shape, word_to_vec_map, word_to_index):
sentence_indices = Input(input_shape, dtype="int32")
embedding_layer = pretrained_embedding_layer(word_to_vec_map, word_to_index)
embeddings = embedding_layer(sentence_indices)
X = LSTM(256, return_sequences=True)(embeddings)
X = Dropout(0.5)(X)
X = LSTM(256, return_sequences=False)(X)
X = Dropout(0.5)(X)
X = Dense(NUM_OF_LABELS)(X)
X = Activation("softmax")(X)
model = Model(inputs=sentence_indices, outputs=X)
return model
Run Code Online (Sandbox Code Playgroud) 似乎select元素和input元素的宽度相等.我怎样才能使input元素占用更多空间并select占用更少空间?
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="input-group mb-3">
<div class="input-group-prepend">
<button class="btn btn-outline-secondary" type="button">Button</button>
</div>
<select class="custom-select" id="inputGroupSelect03">
<option selected>Choose...</option>
<option value="1">One</option>
</select>
<input class="form-control">
</div>Run Code Online (Sandbox Code Playgroud)
我正在使用react-router v.4,我想执行一些返回功能。
我当前的代码如下所示:
<HashRouter>
<Switch>
<Route exact path='/' component={Main}/>
<Route path='/secondview' component={SecondView}/>
<Route path='/traineeships' render={()=>(<Traineeship rootState={this.state} setRootState={this.setState.bind(this)} />)}/>
<Route path='/information-filter' render={()=>(<InformationFilter rootState={this.state} setRootState={this.setState.bind(this)} />)}/>
<Route path='/find-work' render={()=>(<FindWork rootState={this.state} setRootState={this.setState.bind(this)} />)}/>
<Route path='/information-job' render={()=>(<InformationJob rootState={this.state} setRootState={this.setState.bind(this)} />)}/>
<Redirect from='*' to='/' />
</Switch>
Run Code Online (Sandbox Code Playgroud)
我this.props.history.go(-1)在其他组件上尝试了几个选项,但我遇到了未定义的错误。
任何人都知道如何在我的情况下执行返回功能?
javascript ×2
bootstrap-4 ×1
css ×1
html ×1
keras ×1
lstm ×1
python ×1
react-native ×1
reactjs ×1