Вы также можете использовать 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)
Использовать имена параметров в запросе:
Dim command As New SqlCommand("SELECT [username],[password] FROM [stud_table] WHERE [username] = @username", connection)
command.Parameters.AddWithValue("@username", SqlDbType.NVarChar) = Me.UsernameTextBox.Text