ดูบทความที่ชี้แจงข้อยกเว้นและการแสดงภาพเทนเซอร์ในรหัสการเรียนรู้ลึกและสไลด์การใช้งาน Tensorsensor (PDF)
( ณ เดือนกันยายน 2564 M1 Macs มีประสบการณ์ที่ผิดกฎหมายในห้องสมุดเทนเซอร์หลายแห่งที่ติดตั้งผ่าน Anaconda ดังนั้นคุณควรคาดหวังว่า Tensorsensor จะทำงานเฉพาะกับ MAC ที่ใช้ Intel ในขณะนี้ Pytorch ดูเหมือนจะทำงานได้ )
แทนที่จะเป็นข้อความข้อยกเว้นเริ่มต้นต่อไปนี้:
ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 764 is different from 100)
Tensorsensor เพิ่มข้อความพร้อมข้อมูลเพิ่มเติมเกี่ยวกับผู้ประกอบการที่ทำให้เกิดปัญหาและรวมถึงรูปร่างของตัวถูกดำเนินการ:
Cause: @ on tensor operand W w/shape (764, 100) and operand X.T w/shape (764, 200)
นอกจากนี้คุณยังสามารถรับกราฟการคำนวณเต็มรูปแบบสำหรับนิพจน์ที่มีรูปร่างย่อยทั้งหมด
W = torch . rand ( size = ( 2000 , 2000 ), dtype = torch . float64 )
b = torch . rand ( size = ( 2000 , 1 ), dtype = torch . float64 )
h = torch . zeros ( size = ( 1_000_000 ,), dtype = int )
x = torch . rand ( size = ( 2000 , 1 ))
z = torch . rand ( size = ( 2000 , 1 ), dtype = torch . complex64 )
tsensor . astviz ( "b = W@b + (h+3).dot(h) + z" , sys . _getframe ())ให้ผลของแผนผังไวยากรณ์นามธรรมต่อไปนี้ที่มีรูปร่าง:
pip install tensor-sensor # This will only install the library for you
pip install tensor-sensor[torch] # install pytorch related dependency
pip install tensor-sensor[tensorflow] # install tensorflow related dependency
pip install tensor-sensor[jax] # install jax, jaxlib
pip install tensor-sensor[all] # install tensorflow, pytorch, jax
ซึ่งให้โมดูล tsensor ฉันพัฒนาและทดสอบด้วยเวอร์ชันต่อไปนี้
$ pip list | grep -i flow
tensorflow 2.5.0
tensorflow-estimator 2.5.0
$ pip list | grep -i numpy
numpy 1.19.5
numpydoc 1.1.0
$ pip list | grep -i torch
torch 1.10.0
torchvision 0.10.0
$ pip list | grep -i jax
jax 0.2.20
jaxlib 0.1.71
สำหรับการแสดงต้นไวยากรณ์นามธรรม (ASTs) ด้วย tsensor.astviz(...) คุณต้องใช้ dot ที่ปฏิบัติการได้จาก graphviz ไม่ใช่แค่ไลบรารี Python
บน Mac ให้ทำสิ่งนี้ก่อนหรือหลังการติดตั้งเซ็นเซอร์เซ็นเซอร์:
brew install graphviz
บน windows เห็นได้ชัดว่าคุณต้องการ
conda install python-graphviz # Do this first; get's dot executable and py lib
pip install tensor-sensor # Or one of the other installs
ฉันพึ่งพาบรรทัดการแยกวิเคราะห์ที่ได้รับมอบหมายหรือนิพจน์เท่านั้นดังนั้นการชี้แจงและอธิบายกิจวัตรไม่ได้จัดการวิธีการที่แสดงเช่น:
def bar(): b + x * 3
ใช้แทน
def bar():
b + x * 3
ระวังผลข้างเคียง! ฉันไม่ได้รับมอบหมาย แต่ฟังก์ชั่นใด ๆ ที่คุณเรียกว่ามีผลข้างเคียงจะเสร็จสิ้นในขณะที่ฉันประเมินคำสั่งใหม่
ไม่สามารถจัดการ ต่อเนื่องได้
ด้วยแพ็คเกจ threading Python อย่าใช้หลายเธรดการเรียก clarify () แพ็คเกจ multiprocessing น่าจะดี
หมายเหตุ: ฉันได้สร้างตัวแยกวิเคราะห์ของตัวเองเพื่อจัดการเพียงแค่การมอบหมาย / นิพจน์ที่ Tsensor สามารถจัดการได้
$ python setup.py sdist upload หรือดาวน์โหลดและติดตั้งในเครื่อง
$ cd ~ /github/tensor-sensor
$ pip install .