Как исправить неверный синтаксис рядом с '?'

Вы также можете использовать argmax с unravel_index:

def max_by_index(idx, arr):
    return (idx,) + np.unravel_index(np.argmax(arr[idx]), arr.shape[1:])

, например

import numpy as np
a = np.array([[[ 0.25,  0.10 ,  0.50 ,  0.15],
               [ 0.50,  0.60 ,  0.70 ,  0.30]],
              [[ 0.25,  0.50 ,  0.20 ,  0.70],
               [ 0.80,  0.10 ,  0.50 ,  0.15]]])

def max_by_index(idx, arr):
    return (idx,) + np.unravel_index(np.argmax(arr[idx]), arr.shape[1:])


print(max_by_index(0, a))

дает

(0, 1, 2)

0
задан GSerg 19 January 2019 в 09:44
поделиться

1 ответ

Использовать имена параметров в запросе:

Dim command As New SqlCommand("SELECT [username],[password] FROM [stud_table] WHERE [username] = @username", connection)
        command.Parameters.AddWithValue("@username", SqlDbType.NVarChar) = Me.UsernameTextBox.Text
0
ответ дан Vidmantas Blazevicius 19 January 2019 в 09:44
поделиться
Другие вопросы по тегам:

Похожие вопросы: