np.broadcast_to () function using the dimensions and increased expression

numpy NP AS Import 
anchors = np.ones ((2, 3))
Anchor = np.broadcast_to (anchors, (5,) + anchors.shape ) # marked red font expressed relatively new (personal opinion)
Print (Anchor)
Print ( '= an anchors', anchor.shape)
Print ( '(. 5,) = + anchors.shape', (. 5,) + anchors.shape)
Print ( '(. 4,) + (. 5,) = + anchors.shape' , (4,) + (5 ,) + anchors.shape)


was as follows:

[[[1. 1. 1.]
[1. 1. 1.]]

[[1. 1. 1.]
[1. 1. 1.]]

[[1. 1. 1.]
[1. 1. 1.]]

[[1. 1. 1.]
[1. 1. 1.]]

[[1. 1. 1.]
[1. 1. 1.]]]
anchors= (5, 2, 3)
(5,)+anchors.shape= (5, 2, 3)
(4,)+(5,)+anchors.shape= (4, 5, 2, 3)

Guess you like

Origin www.cnblogs.com/tangjunjun/p/11931092.html