Skip to content

Instantly share code, notes, and snippets.

@guilhermefgs
Last active October 27, 2019 06:08
Show Gist options
  • Save guilhermefgs/80b6fd2e313a101189de5107faaf7f5d to your computer and use it in GitHub Desktop.
Save guilhermefgs/80b6fd2e313a101189de5107faaf7f5d to your computer and use it in GitHub Desktop.
Inicialização aleatória dos parâmetros theta em redes neurais
def randomInit(input_layer_size, hidden_layer_size, num_labels):
# Parâmetros da primeira camada (incluindo bias)
# As matrizes têm formato (num_entradas, num_saidas)
size1 = (hidden_layer_size, input_layer_size+1)
theta1_ini = np.random.normal(0, .1, size=size1)
# Parâmetros da primeira camada (incluindo bias)
size2 = (num_labels, hidden_layer_size+1)
theta2_ini = np.random.normal(0, .1, size=size2)
return (theta1_ini, theta2_ini)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment