動作環境
GeForce GTX 1070 (8GB)
ASRock Z170M Pro4S [Intel Z170chipset]
Ubuntu 16.04 LTS desktop amd64
TensorFlow v1.2.1
cuDNN v5.1 for Linux
CUDA v8.0
Python 3.5.2
IPython 6.0.0 -- An enhanced Interactive Python.
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
scipy v0.19.1
geopandas v0.3.0
MATLAB R2017b (Home Edition)
Error
test_shape_171123.py
import numpy as np
xc = np.array([[3,1,4],[1,5,9]])
cf = np.array([2,7])
print(xc/cf)
run
$ python3 test_shape_171123.py
Traceback (most recent call last):
File "test_shape_171123.py", line 6, in <module>
print(xc/cf)
ValueError: operands could not be broadcast together with shapes (2,3) (2,)
今日は20回くらい怒られている。
[2,7]
から[[2,2,2],[7,7,7]]
を作る必要があるようだ。
code
test_shape_171123.py
import numpy as np
xc = np.array([[3,1,4],[1,5,9]])
cf = np.array([2,7])
print(xc)
print('--case1:')
cf1 = np.tile(cf, (1,3)).reshape(2,3)
print(cf1)
print('--case2:')
cf2 = np.tile(cf, (3,1)).reshape(2,3)
print(cf2)
#print(xc/cf)
print('--case3:')
#cf3 = np.repeat(cf, 3, axis=0).reshape(2,3)
cf3 = np.repeat(cf, len(xc[0]), axis=0).reshape(len(xc),len(xc[0]))
print(cf3)
print('--xc/cf3')
print(xc/cf3)
run
$ python3 test_shape_171123.py
[[3 1 4]
[1 5 9]]
--case1:
[[2 7 2]
[7 2 7]]
--case2:
[[2 7 2]
[7 2 7]]
--case3:
[[2 2 2]
[7 7 7]]
--xc/cf3
[[ 1.5 0.5 2. ]
[ 0.14285714 0.71428571 1.28571429]]
case3で実現できた。
circumcenterSphTri()完成。