我有连接两个数组的代码。在
import numpy as np
from hmmlearn import hmm
model = hmm.MultinomialHMM(n_components=3, n_iter=10,algorithm='map',tol=0.00001)
sequence3 = np.array([[2, 1, 0, 1]]).T
sequence4 = np.array([[2, 1, 0, 1, 1]]).T
sample = np.concatenate([sequence3, sequence4])
lengths = [len(sequence3), len(sequence4)]
model.fit(sample,lengths)
而且工作正常。但现在如果我有两个以上的数组。假设我有10个数组。我怎么能做同样的过程?在
^{pr2}$
为了连接多个数组,您只需将该数组与所有先前的数组串联起来。在
您可以使用vstack
也就是说
将数组存储为一个列表,比如
array_list
样品:
^{pr2}$希望有帮助!在
相关问题 更多 >
编程相关推荐