error in plotting in the visualization tutorial

48 views
Skip to first unread message

Ahmed Abuali

unread,
Mar 22, 2023, 11:22:34 PM3/22/23
to Machine Learning for Physicists
Hello everyone,

I just started this course, and I am not expert in python
 
I tried the visualization code for the one hidden layer with 3 neurons
but I get this error

ValueError: cannot reshape array of size 1 into shape (100,100)

I think this is line that produce the error

img=ax[1].imshow(np.reshape(y_out,[M,M]),origin='lower', extent=[y0range[0],y0range[1],y1range[0],y1range[1]])

Can you help me resolve this error?

Ahmed Abuali

unread,
Mar 22, 2023, 11:26:42 PM3/22/23
to Machine Learning for Physicists
here is the call
visualize_network(weights=[ [
    [0.2,0.9],   # weights of 2 input neurons for 1st hidden neuron
    [-0.5,0.3],  # weights of 2 input neurons for 2nd hidden
    [0.8,-1.3]   # weights of 2 input neurons for 3rd hidden
    ],
    [
        [-0.3,0.7,0.5] # weights of 3 hidden neurons for output
    ] ],
    biases=[
        [0.1,-0.5,-0.5], # biases of 3 hidden neurons
        [-.2] # bias for output neuron
            ],
    activations=['jump',# activation for hidden
                 'linear' # activation for output
                ],
    y0range=[-3,3], y1range=[-3,3])

Ahmed Abuali

unread,
Mar 22, 2023, 11:34:55 PM3/22/23
to Machine Learning for Physicists
I also discovered that the code is working if I have
activations=['jump',# activation for hidden
                 'jump' # activation for output

instead of

activations=['jump',# activation for hidden
                 'linear' # activation for output

Ahmed Abuali

unread,
Mar 22, 2023, 11:40:38 PM3/22/23
to Machine Learning for Physicists
and if I use
activations=['jump',# activation for hidden
                 'sigmoid' # activation for output

it gives the behavior expected from 
activations=['jump',# activation for hidden
                 'linear' # activation for output

Reply all
Reply to author
Forward
0 new messages