- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用 keras(tensorflow backend) 来构建我的 lstm 网络,这是我的代码:
from keras.models import Sequential,Model
from keras.layers import LSTM,Conv1D,Dense,MaxPooling1D,GlobalMaxPooling1D,Input,Concatenate
from keras.optimizers import Adam
x_input = Input(shape=(None,x_train.shape[-1]),name='input')
x_mid = Conv1D(32,4, activation='relu')(x_input)
x_mid = MaxPooling1D(3)(x_mid)
x_mid = Conv1D(32,4,activation = 'relu')(x_mid)
x_mid = LSTM(32,dropout=0.1, recurrent_dropout=0.2,activation='relu')(x_mid)
x_mid = Dense(1,activation='sigmoid')(x_mid)
other_input = Input(shape=(x_blend_train.shape[-1],),name='clfs_input')
merge_x = concatenate(inputs= [x_mid,other_input],axis = -1)
output = Dense(32,activation='relu')(merge_x)
output = Dense(1,activation='sigmoid')(output)
model = Model(inputs=[x_input,other_input],outputs=output)
model.compile(optimizer='adam',loss=['binary_crossentropy'],metrics=['acc'])
model.summary()
Layer (type) Output Shape Param # Connected to
==================================================================================================
input (InputLayer) (None, None, 49) 0
__________________________________________________________________________________________________
conv1d_56 (Conv1D) (None, None, 32) 6304 input[0][0]
__________________________________________________________________________________________________
max_pooling1d_26 (MaxPooling1D) (None, None, 32) 0 conv1d_56[0][0]
__________________________________________________________________________________________________
conv1d_57 (Conv1D) (None, None, 32) 4128 max_pooling1d_26[0][0]
__________________________________________________________________________________________________
lstm_26 (LSTM) (None, 32) 8320 conv1d_57[0][0]
__________________________________________________________________________________________________
dense_59 (Dense) (None, 1) 33 lstm_26[0][0]
__________________________________________________________________________________________________
clfs_input (InputLayer) (None, 1) 0
__________________________________________________________________________________________________
concatenate_20 (Concatenate) (None, 2) 0 dense_59[0][0]
clfs_input[0][0]
__________________________________________________________________________________________________
dense_60 (Dense) (None, 32) 96 concatenate_20[0][0]
__________________________________________________________________________________________________
dense_61 (Dense) (None, 1) 33 dense_60[0][0]
==================================================================================================
x_train.shape: (1350, 14, 49) x_blend_train.shape: (1350, 1) y_train.shape: (1350, 1)
tensorflow version:'1.8.0-rc1' keras version:'2.1.6'
model.fit( x={'input':x_train,'clfs_input':x_blend_train}, y=y_train, batch_size=64, epochs=10)
InvalidArgumentError: slice index 0 of dimension 0 out of bounds.
[[Node: lstm_25/strided_slice_13 = StridedSlice[Index=DT_INT32, T=DT_FLOAT, begin_mask=0, ellipsis_mask=0, end_mask=0, new_axis_mask=0, shrink_axis_mask=1, _device="/job:localhost/replica:0/task:0/device:CPU:0"](lstm_25/transpose, loss_11/dense_58_loss/Const_2, lstm_25/strided_slice_9/stack_2, lstm_25/strided_slice_9/stack_2)]]
Epoch 1/10
---------------------------------------------------------------------------
InvalidArgumentError Traceback (most recent call last)
/opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
1321 try:
-> 1322 return fn(*args)
1323 except errors.OpError as e:
/opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py in _run_fn(feed_dict, fetch_list, target_list, options, run_metadata)
1306 return self._call_tf_sessionrun(
-> 1307 options, feed_dict, fetch_list, target_list, run_metadata)
1308
/opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py in _call_tf_sessionrun(self, options, feed_dict, fetch_list, target_list, run_metadata)
1408 self._session, options, feed_dict, fetch_list, target_list,
-> 1409 run_metadata)
1410 else:
InvalidArgumentError: slice index 0 of dimension 0 out of bounds.
[[Node: lstm_25/strided_slice_13 = StridedSlice[Index=DT_INT32, T=DT_FLOAT, begin_mask=0, ellipsis_mask=0, end_mask=0, new_axis_mask=0, shrink_axis_mask=1, _device="/job:localhost/replica:0/task:0/device:CPU:0"](lstm_25/transpose, loss_11/dense_58_loss/Const_2, lstm_25/strided_slice_9/stack_2, lstm_25/strided_slice_9/stack_2)]]
During handling of the above exception, another exception occurred:
InvalidArgumentError Traceback (most recent call last)
<ipython-input-66-c2316b8cd20c> in <module>()
----> 1 model.fit( x={'input':x_train,'clfs_input':x_blend_train}, y=y_train, batch_size=64, epochs=10)
2 y_pred = model.predict({'input':x_train,'clfs_input':x_blend_test})
/opt/conda/lib/python3.6/site-packages/Keras-2.1.6-py3.6.egg/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, **kwargs)
1031 initial_epoch=initial_epoch,
1032 steps_per_epoch=steps_per_epoch,
-> 1033 validation_steps=validation_steps)
1034
1035 def evaluate(self, x=None, y=None,
/opt/conda/lib/python3.6/site-packages/Keras-2.1.6-py3.6.egg/keras/engine/training_arrays.py in fit_loop(model, f, ins, out_labels, batch_size, epochs, verbose, callbacks, val_f, val_ins, shuffle, callback_metrics, initial_epoch, steps_per_epoch, validation_steps)
193 ins_batch[i] = ins_batch[i].toarray()
194
--> 195 outs = f(ins_batch)
196 if not isinstance(outs, list):
197 outs = [outs]
/opt/conda/lib/python3.6/site-packages/Keras-2.1.6-py3.6.egg/keras/backend/tensorflow_backend.py in __call__(self, inputs)
2489 session = get_session()
2490 updated = session.run(fetches=fetches, feed_dict=feed_dict,
-> 2491 **self.session_kwargs)
2492 return updated[:len(self.outputs)]
2493
/opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata)
898 try:
899 result = self._run(None, fetches, feed_dict, options_ptr,
--> 900 run_metadata_ptr)
901 if run_metadata:
902 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)
/opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
1133 if final_fetches or final_targets or (handle and feed_dict_tensor):
1134 results = self._do_run(handle, final_targets, final_fetches,
-> 1135 feed_dict_tensor, options, run_metadata)
1136 else:
1137 results = []
/opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata)
1314 if handle is None:
1315 return self._do_call(_run_fn, feeds, fetches, targets, options,
-> 1316 run_metadata)
1317 else:
1318 return self._do_call(_prun_fn, handle, feeds, fetches)
/opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
1333 except KeyError:
1334 pass
-> 1335 raise type(e)(node_def, op, message)
1336
1337 def _extend_graph(self):
最佳答案
让我们进行一次观察,看看会发生什么。单个观察具有以下形状:(14 , 49)。
在第一个 Conv1D 层之后,它将变为 (11,32)(内核大小为 4,步幅为 1)。在第一个 Maxpooling1D 层之后,它将转到 (3 , 32) (因为您没有设置步幅,它将默认为您的池大小为 3)。如果我们查看您的第二个 conv1D 层,它的内核大小等于 4,这大于数据帧的第一个维度的数量。
我建议将第一行设置为:
x_input = Input(shape=(x_train.shape[-2],x_train.shape[-1]),name='input')
关于tensorflow - 如何处理keras : erro:slice index 0 of dimension 0 out of bounds,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50385447/
在许多在线资源中,可以找到“内存”、“带宽”、“延迟”绑定(bind)内核的不同用法。在我看来,作者有时会使用他们自己对这些术语的定义,我认为这对某人做出明确区分非常有益。 据我了解:带宽绑定(bin
FIFO、LIFO 和LC Branch and Bound 有什么区别? 最佳答案 Branch & Bound 通过使用估计边界来限制可能解决方案的数量来发现完整搜索空间内的分支。不同的类型(FI
我有一个网页,其中有一些 Kendo 控件(例如下拉菜单和按钮)可以正常工作,但是添加Grid 会导致问题。 @(Html.Kendo().Grid(Model).Name("grid").Colu
术语“CPU 限制”和“I/O 限制”是什么意思? 最佳答案 这非常直观: 如果 CPU 更快,程序就会运行得更快,即程序的大部分时间只是使用 CPU(进行计算),则该程序是 CPU 密集型。 计算
我在以下代码段中遇到问题并发出警告,希望您能帮助我: fprintf (fp, "%dd%d+%d ", pMobIndex->mana[DICE_NUMBER], DICE_NUMBER 在我
swift 2 let gap = CGFloat(randomInRange(StackGapMinWidth...maxGap)) Missing argument label 'range:'
swift 2 let gap = CGFloat(randomInRange(StackGapMinWidth...maxGap)) Missing argument label 'range:'
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 关闭 6 年前。 这个问题是由于打字错误或无法再重现的问题引起的。虽然类似的问题可能是on-topic在
我想在gcc8.2下启用数组边界检查,这样可以帮助在编译期间检查数组下标是否越界,它可能会给出如下警告:数组下标高于数组边界 [-Warray-bounds] 我使用 coliru 做了一个演示: #
我只是想知道在 Apple API 中的什么地方定义了变量“bounds.minX”、“bounds.maxX”?我查看了“UIView”和“CGRect”文档,但似乎找不到它? 最佳答案 它包含在"
我想覆盖整个屏幕。我想将其框架设置为覆盖整个屏幕。浏览堆栈溢出时,我发现了这两种不同的设置 View 框架以覆盖屏幕的方法: [UIScreen mainScreen].bounds [UIApplc
在协程中执行 IO 绑定(bind)函数(例如,从后端请求数据)给了我一个优势,即在请求结果可用之前暂停它的执行,对吗?但是,受 CPU 限制的函数(例如,解析一个巨大的文本文件)不会“等待”任何东西
public class ChampionsLeague> extends League{ ... 如何创建此类的实例? ChampionsLeague league = new ChampionsL
我遇到了以下问题: 我有这些类和接口(interface)定义 public abstract class ViewModelRefreshPostListFragment> extends
我注意到在使用 (Swift 4.0) 的 IOS X 代码中,我至少可以通过以下两种方式请求 View 的高度 V: V.bounds.size.height 和... V.bounds.heigh
swift 中 bounds.size.width 和 bounds.width 有什么区别?他们会返回同样的东西吗?谢谢! 最佳答案 bounds 是 UIView 的 CGRect 结构属性,其中
在我看来不可能包含 Integer.MAX_VALUE和Long.MAX_VALUE创建 IntStream 时尽可能使用随机值或LongStream使用 java.util.Random 的边界类。
我有二叉树类: public class BinaryTree> extends AbstractTree { protected TreeNode root;
我最近做了并更新了我的 Xamarin iOS 项目,我曾经能够调用以下代码来检索屏幕宽度和高度: if (orientation == UIInterfaceOrientation.Landscap
我仍然不明白为什么我收到这个警告 array subscript is above array bounds [-Warray-bounds] 对于一个小的 C 代码如下: #include #in
我是一名优秀的程序员,十分优秀!