public float[] FillSmall(AttentionParameter p) { m_blob_bottom.Reshape(2, 1, 1, 1); // timesteps = 2, batch = 1, input = 1 float[] rgData = convertF(m_blob_bottom.mutable_cpu_data); // shape (2, 1, 1, 1) // timestep 1, batch 1 rgData[0] = 1.11f; rgData[1] = 2.11f; m_blob_bottom.mutable_cpu_data = convert(rgData); m_blobState.Reshape(new List <int>() { 1, (int)p.dim }); List <int> rgShape = Utility.Clone <int>(m_blob_bottom.shape()); while (rgShape.Count > 2) { rgShape.RemoveAt(rgShape.Count - 1); } m_blobClip.Reshape(rgShape); m_blobClip.SetData(1); BottomVec.Clear(); BottomVec.Add(m_blob_bottom); BottomVec.Add(m_blobState); BottomVec.Add(m_blobClip); return(rgData); }
public float[] Fill2(AttentionParameter p) { m_blob_bottom.Reshape(3, 1, 32, 1); // timesteps = 3, batch = 1, input = 32 float[] rgData = convertF(m_blob_bottom.mutable_cpu_data); for (int t = 0; t < m_blob_bottom.num; t++) { for (int i = 0; i < 32; i++) { int nIdx = t * 32 + i; rgData[nIdx] = (t + 1) + (i * 0.01f); } } m_blob_bottom.mutable_cpu_data = convert(rgData); m_blobState.Reshape(new List <int>() { 1, (int)p.dim }); List <int> rgShape = Utility.Clone <int>(m_blob_bottom.shape()); while (rgShape.Count > 2) { rgShape.RemoveAt(rgShape.Count - 1); } m_blobClip.Reshape(rgShape); m_blobClip.SetData(1); BottomVec.Clear(); BottomVec.Add(m_blob_bottom); BottomVec.Add(m_blobState); BottomVec.Add(m_blobClip); return(rgData); }