“ input_length”是什么意思?

时间:2019-08-15 03:03:46

标签: tensorflow

数据有4个时间戳,但是嵌入的input_length = 3,那么input_length的含义是什么?


Private Sub UserForm_Initialize()
myValue = inputbox("Pre-Enter some Default Values?(Y/N)")

With ListBox1
   .AddItem "Listbox1-A"
   .AddItem "Listbox1-B"
   .AddItem "Listbox1-C"
End With

With ListBox2
   .AddItem "Listbox2-A"
   .AddItem "Listbox2-B"
   .AddItem "Listbox2-C"
End With

With ListBox3
   .AddItem "Listbox3-A"
   .AddItem "Listbox3-B"
   .AddItem "Listbox3-C"
End With

With ListBox4
   .AddItem "Listbox4-A"
   .AddItem "Listbox4-B"
   .AddItem "Listbox4-C"
End With

With ListBox5
   .AddItem "Listbox5-A"
   .AddItem "Listbox5-B"
   .AddItem "Listbox5-C"
End With

With ListBox6
   .AddItem "Listbox6-A"
   .AddItem "Listbox6-B"
   .AddItem "Listbox6-C"
End With

With ListBox7
   .AddItem "Listbox7-A"
   .AddItem "Listbox7-B"
   .AddItem "Listbox7-C"
End With
With ListBox8
   .AddItem "Listbox8-A"
   .AddItem "Listbox8-B"
   .AddItem "Listbox8-C"
End With

If UCase(myValue) = "Y" Then
ListBox1.Value = "Listbox1-B"
ListBox2.Value = "Listbox2-B"
ListBox3.Value = "Listbox3-B"
ListBox4.Value = "Listbox4-B"
ListBox5.Value = "Listbox5-B"
ListBox6.Value = "Listbox6-B"
ListBox7.Value = "Listbox7-B"
ListBox8.Value = "Listbox8-B"
End If
End Sub


Private Sub CommandButton1_Click()
MsgBox UserForm4.ListBox1.Value & vbCrLf & _
UserForm4.ListBox2.Value & vbCrLf & _
UserForm4.ListBox3.Value & vbCrLf & _
UserForm4.ListBox4.Value & vbCrLf & _
UserForm4.ListBox5.Value & vbCrLf & _
UserForm4.ListBox6.Value & vbCrLf & _
UserForm4.ListBox7.Value & vbCrLf & _
UserForm4.ListBox8.Value & vbCrLf

End
End Sub

1 个答案:

答案 0 :(得分:0)

根据官方文档here

  

input_length :输入序列的长度,如果为常数。这个   如果要连接Flatten然后Dense,则需要参数   上游的层(没有它,密集输出的形状不能是   计算)。

from tensorflow import keras
import numpy as np

model = keras.models.Sequential()
model.add(keras.layers.Embedding(input_dim=2, output_dim=3, input_length=4))
# the model will take as input an integer matrix of size (batch, input_length).

input_array = np.array([[0,0,0,0]])
model.compile('rmsprop', 'mse')
output_array = model.predict(input_array)
print(output_array)

上面的方法工作正常,但是如果将input_length更改为3,则会出现以下错误:

  

ValueError:检查输入时出错:预期的embedding_input为   形状为(3,)但数组为形状(4,)