В рамках моего упражнения с Numpy я попробовал приведенный ниже код.
import numpy as np
inputAttributes = 32
outputAttributes = 64
noOfElements = 3
inputData = np.random.random((noOfElements, inputAttributes))
weights = np.random.random((outputAttributes, inputAttributes))
extrawegiths = np.random.random((outputAttributes, outputAttributes))
extraInput = np.random.random((outputAttributes,))
eachLayerOutput =[]
for eachData in inputData:
print ("---------------")
print (weights.shape, eachData.shape)
print (extrawegiths.shape, extraInput.shape)
result = np.dot(weights,eachData) + np.dot(extrawegiths, extraInput)
print (result.shape)
print ("---------------")
Мой вывод был следующим:
((64, 32), (32,))
((64, 64), (64,))
(64,)
Если я интерпретирую, тогда
(64, 32 ) * (32, ) => (64, )
(64, 64 ) * (64, ) => (64, )
(64, ) + (64, ) => (64, )
Пока все хорошо, теперь я изменяю форму extraInput на #, добавляя '1'
extraInput = np.random.random((outputAttributes, 1)
Теперь я получил результат, который не могу понять.
((64, 32), (32,))
((64, 64), (64, 1))
(64, 64)
Если я интерпретирую, тогда
(64, 32 ) * (32, ) => (64, )
(64, 64 ) * (64,1) => (64,1)
(64, ) + (64, 1) => (64, 64 )
КАК (64,) + (64, 1) ВЕДЕТ (64,64)?