[英]How to put a vector in INDArray of ND4J?
INDArray a = Nd4j.zeros(2,2);
a.put(1,Nd4j.create(nw float[]{1.0,2.0}));
我已經嘗試了上面的代碼,但它給出了以下錯誤
java.lang.IllegalArgumentException: Element must be a scalar
我是ND4J lib的新手。 有沒有辦法直接放置向量?
/**
* Inserts the element at the specified index
*
* @param indices the indices to insert into
* @param element a scalar ndarray
* @return a scalar ndarray of the element at this index
*/
INDArray put(int[] indices, INDArray element);
我可以在源代碼中看到上述方法,但是為此,我將需要創建將消耗內存的int數組。
您正在尋找的方法是putRow
,它具有所需的簽名:
INDArray putRow(int row, INDArray toPut);
還有putColumn
對於列也類似地工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.