0
A
回答
0
多維數組應按主要順序排列。這應該是numpy的默認值。
下面是一個例子來說明這個
from tensorflow.core.example import example_pb2
from google.protobuf import json_format
import tensorflow as tf
import numpy as np
# Create a 2-d matrix
m = np.arange(4).reshape([2,2])
print "row 1: {0}".format(m[0,:])
print "row 2: {0}".format(m[1,:])
# Construct the Example proto
e = example_pb2.Example()
e.features.feature['data'].int64_list.value.extend(m.flatten())
print "Json format"
print json_format.MessageToJson(e)
p = tf.parse_single_example(e.SerializeToString(), {'data': tf.FixedLenFeature([2,2], dtype=tf.int64)})
sess = tf.Session()
sess.run(tf.initialize_all_variables())
w = sess.run(p)
print "Parsed data"
print "row 1: {0}".format(w["data"][0,:])
print "row 2: {0}".format(w["data"][1,:])
它產生輸出
row 1: [0 1]
row 2: [2 3]
Json format
{
"features": {
"feature": {
"data": {
"int64List": {
"value": [
"0",
"1",
"2",
"3"
]
}
}
}
}
}
Parsed data
row 1: [0 1]
row 2: [2 3]
相關問題
- 1. C++主要表達式 - 它是否是主要表達式?
- 2. C主要表達式 - 它是否是主要表達式?
- 3. 函數聲明主要與外還主要用C
- 4. Android矩陣setValues()行主要或列主要
- 5. 遍歷行主要存儲列中的數組主要順序
- 6. 混淆與行主要和列主要矩陣乘法在hlsl
- 7. 切換行主要維到列主要維
- 8. 將1D NumPy數組從(隱式)行主要更改爲列主要次序
- 9. 變量名稱更改顛簸SemVer主要還是次要?
- 10. 列主要訂單
- 11. 要使用shouldRasterize還是不要使用
- 12. 主要不執行...`
- 13. 主要還是頭文件會讓編譯器先執行?
- 14. 錯誤:主要格式爲0(libsndfile,QT)
- 15. Excel中的主要格式問題 - VLOOKUP
- 16. 主要錯誤「0」與字典格式
- 17. 使用行主要在OpenGL着色器
- 18. 居中CSS/HTML主要格
- 19. Emacs的股票主要模式列表
- 20. ASP.NET/IIS 7 - 使用主要
- 21. 使用「^」的主要原因
- 22. Python:使用主要功能
- 23. 使用MD-主要在DIV
- 24. RabbitMQ的主題格式 - 下主要話題子話題
- 25. 什麼是主要的方式豚
- 26. 需要使用鎖還是不行?
- 27. 主要ManyToOne W/O主要ID密鑰
- 28. 例外在線程「主要」 java.nosuchmethoderror:主要
- 29. MVC5主鍵總是需要序列
- 30. 行和列主要在opencl和pyopencl