Ad
Making A 0 To Nxn Matrix And Reshape It To Pairs
Maybe I am wrong and I don't know how to search for it.
I need to get a list of pairs
(0,0) (0,1) (0,2) ... (0,999) ... (999,999)
To put these values into a neural network and get the result - just a vector of length (999*999)
Then I can reshape it to (999,999) and have a map of outputs.
So, naive approach is to use
for i in range(0, 999):
for j in range(0, 999):
list.add(predict(i,j))
But it is impossible to use batches
Another naive approach is
numbers=[]
for i in range(0, 999):
for j in range(0, 999):
numbers.append([i,j])
and this works in batches.
Is there any more elegant solution?
Ad
Answer
Try this:
target_list = np.array([(i,j) for i in range(1000) for j in range(1000)])
This print(target_list)
will give desired list in numpy array format:
[[ 0 0]
[ 0 1]
[ 0 2]
...
[999 997]
[999 998]
[999 999]]
Ad
source: stackoverflow.com
Related Questions
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Can't turn off Javascript using Selenium
- → WebDriver click() vs JavaScript click()
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module
Ad