I am getting a ValueError when trying to check if two lists are the same, why is this and how can I fix this

I am using pickle to save something to a file, and am trying to check if the thing loaded back in is the exact same as the thing that was saved to the file, for later in the program and am receiving the error message:

  File "(Directory blurred for privacy)", line 28, in <module>
    if newvalues == myvalues:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

when I try to check if they are equal to each other. Does anyone know how to fix this? I’ve tried iterating through them both and checking if each element is the same, and if any element is different, then it tells me, but this also returns the same error. I am using python 3.10 in Pycharm. The outputs from print(type(myvalues)) and print(type(newvalues)) are both the same thing, which is <class 'list'>

my code is here:

print ("start")
import mnist_loader
training_data, validation_data, test_data = mnist_loader.load_data_wrapper()

import network
net = network.Network([784, 30, 10]) # amount of neurons in each layer is the numbers

net.SGD(training_data, 2, 10, 3.0, test_data = test_data)

myvalues = net.getWeightsAndBiases()


# Saving it - not part of the code from book
print("n n n")
with open("data.pickle", "wb") as file:
    pickle.dump(myvalues, file)

with open("data.pickle", "rb") as file:
    newvalues = pickle.load(file)

print(newvalues)

print("myvalues is:", type(myvalues))
print("newvalues is:", type(newvalues))
if newvalues == myvalues:
    print("working")

the imports come from this github repo: https://github.com/unexploredtest/neural-networks-and-deep-learning with an addition to the Network class in the network file of:

def getWeightsAndBiases(self):
    weightsandbiases = [self.weights, self.biases]
    print(weightsandbiases)
    return weightsandbiases

I tried to see if this error was encountered before, and found this question: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all(). I tried what was suggested on there, but it didn’t solve the problem.

here are the values stored:
myvalues:

[[array([[ 0.49047849, -0.49061768,  1.38129925, ...,  1.38365421,
        -2.84816588,  1.33435502],
       [ 0.14265502, -0.40701424, -0.06344381, ..., -0.04221331,
         1.87971909,  0.16228496],
       [ 1.25865165,  0.5694624 , -0.15033885, ..., -0.33268354,
         1.82849422, -0.32053569],
       ...,
       [-0.86875935, -1.31803218, -0.06188464, ...,  0.80358709,
        -1.22506318,  0.65488229],
       [ 0.72230337,  1.20813743,  0.70311973, ..., -1.31394859,
        -1.58026529,  1.573237  ],
       [ 0.75231614,  1.82261382,  0.28055294, ...,  0.63589566,
         1.54549887, -0.09006421]]), array([[ 9.04625312e-01, -1.20168740e+00, -2.05344286e+00,
         9.95282006e-01, -2.61128392e-01,  2.46883716e+00,
        -1.26605928e+00, -2.87461934e-01, -2.55345158e+00,
         3.95568507e+00,  6.47950996e-01,  2.92748875e-01,
        -1.90249337e+00, -2.05367861e+00,  1.17277862e+00,
         1.57364635e-01, -2.35467086e+00, -2.06776136e+00,
        -8.59204716e-02, -2.26256190e-01, -1.03518297e+00,
        -2.54459855e+00, -1.89909493e+00, -1.99529114e+00,
        -1.89778623e+00, -1.74062008e+00,  1.33135961e+00,
         1.66467987e-01,  3.65705086e-01,  1.15453112e+00],
       [ 5.18282670e-01,  2.10463982e+00,  2.22985297e-01,
         9.32875441e-02,  7.28948913e-01, -1.10041794e+00,
        -1.98894338e+00,  1.77096789e+00,  2.94633320e+00,
        -1.42998907e+00, -1.45059944e+00,  1.33818451e+00,
         2.37342106e+00, -2.77977954e+00, -2.89356946e+00,
         3.48555860e-01, -1.47593219e+00, -7.17198708e-01,
        -2.04548364e+00, -1.60860270e-02,  2.28442674e+00,
        -2.13940877e+00, -2.34960215e+00,  1.45710833e+00,
        -2.06243860e-02,  3.60329517e-01, -1.54618740e+00,
         2.19487096e+00, -1.04334123e-01, -2.94963266e+00],
       [-1.25268187e+00,  1.03468220e+00, -2.09360677e+00,
         2.72615924e+00,  8.03204286e-01, -1.21663915e+00,
        -3.14265961e+00, -2.99772834e-01, -6.55293117e-01,
        -1.85560311e+00, -1.69062463e-01,  1.53853932e-01,
         2.25068573e+00,  1.95227101e+00,  1.51207030e+00,
        -1.92508002e+00, -2.74164612e+00, -2.93852455e+00,
         2.01606172e+00, -6.91112599e-02, -2.27444607e+00,
        -2.75360145e+00, -1.62466484e-01,  1.68692850e+00,
         5.08041338e-01,  1.62613626e+00, -5.29857957e-02,
        -1.65836590e+00, -1.29237245e-03,  1.42649470e+00],
       [-1.00819993e+00,  2.63043465e+00, -8.48382777e-02,
        -4.38687260e-01,  3.76851240e-02,  5.60457581e-01,
        -1.86550332e+00, -4.34641085e-01, -3.02091630e+00,
        -1.55467958e+00,  7.91021890e-01,  1.23804246e+00,
         8.97229505e-01,  4.29841772e-01, -2.42525138e+00,
        -1.50064714e+00, -1.63826402e+00,  3.17469593e+00,
        -3.22054928e+00,  1.28392045e-01, -2.31741089e+00,
        -2.01552447e+00, -9.76992399e-01, -2.11558724e+00,
         1.92055199e+00,  5.55657968e-02, -1.75658363e+00,
        -2.46376324e+00,  1.73383489e+00,  1.56852876e+00],
       [-2.69408613e+00, -1.65159886e-01,  1.14444474e+00,
         1.23856668e+00,  1.02779879e+00,  2.81014023e+00,
         1.94193324e+00,  4.19896377e+00,  4.76766390e-01,
        -1.59098892e+00, -3.46217943e+00, -8.54517359e-01,
        -3.45234416e+00,  6.83242926e-01,  3.85724030e-02,
        -1.52278124e+00, -3.58015741e+00, -1.08273825e+00,
        -8.58495236e-02, -9.03825817e-01,  6.78730044e-01,
         5.18992143e-01,  3.42742226e+00, -1.52145368e+00,
         4.42189117e-01, -3.51066960e-01,  3.23080044e-01,
        -1.57079554e+00,  1.56477334e+00,  6.25506107e-01],
       [-3.33084155e-01, -2.79916035e+00,  5.22989199e-01,
         1.38178594e+00,  3.46671869e-01, -2.52869916e+00,
        -2.85003881e+00,  3.28334995e-01, -2.84497518e+00,
        -3.13336002e+00,  1.80758606e+00, -2.91602798e-01,
        -1.37399163e+00,  9.64047229e-01, -1.64202622e+00,
        -1.16234051e+00, -9.29535117e-01,  1.41014006e+00,
        -2.46834534e-01, -2.55373025e+00,  3.09016395e+00,
         1.98639570e+00,  1.10538587e+00,  4.80455892e-01,
        -1.63467864e+00,  7.28759567e-01,  2.64827251e+00,
         4.19659350e+00,  1.74234240e+00, -1.03982207e+00],
       [-1.99266677e+00, -3.45359895e+00, -1.66118838e+00,
        -6.86597421e-01, -3.64325347e-01,  2.37331770e+00,
         2.69295889e+00, -1.47113808e+00,  1.39082250e+00,
        -1.46233207e+00,  1.33042898e+00, -2.33113544e+00,
        -1.69593344e+00, -1.08305993e+00,  1.47304532e+00,
        -8.01031798e-01, -1.39920442e-01, -3.70400598e-01,
        -6.01091586e-01, -2.16153982e+00,  9.10587323e-01,
        -1.50354389e+00, -2.94728783e+00,  1.89153136e+00,
         1.43422568e+00, -6.14883762e-01, -1.29433499e+00,
         3.50730738e-01,  4.83855845e-03, -1.75349388e+00],
       [-1.65761588e+00, -5.63733247e-01,  4.25340960e-01,
         2.12352772e+00,  5.11942027e-01,  2.34213260e-01,
        -1.07488277e+00, -1.74688310e-01,  2.17174402e-02,
         2.48123976e-02, -3.62391678e-01,  6.56484593e-01,
         7.67530180e-01, -2.79774226e+00, -1.52769623e-01,
        -1.34026002e+00, -7.56261158e-01, -4.26031821e-01,
        -4.15734416e-01, -5.99522808e-01, -1.37719915e+00,
        -7.67536696e-01,  2.65846043e-01,  1.55756415e-01,
         6.99817419e-02,  5.52418194e-01, -3.16887735e+00,
         6.30433024e-01, -1.71636457e+00, -8.35886404e-01],
       [ 3.21696401e-01, -1.71443017e+00,  3.76632012e+00,
        -1.83856335e+00,  1.47475018e+00,  1.59866379e+00,
        -2.73854827e+00, -7.24335260e-02,  2.65913111e+00,
        -1.57314023e+00,  2.53103461e+00, -1.66971607e+00,
         9.40072925e-01,  9.69474126e-01, -1.69713625e+00,
        -9.04140008e-01, -2.44440263e+00, -5.97944024e-01,
         2.19066743e+00, -2.55224131e+00, -2.42208274e+00,
        -1.39494323e+00, -2.75270420e+00, -2.01258784e+00,
        -1.65333206e+00,  2.14839247e-01,  5.38008934e-01,
        -4.48039975e+00,  1.68560318e+00, -1.21934927e+00],
       [ 3.06599211e+00, -7.07372169e-01, -6.88577595e-01,
         6.59071311e-01, -2.00414045e+00,  4.02737209e+00,
         3.42991453e+00, -4.16059766e+00,  7.54238608e-03,
        -1.29674288e+00, -1.39663044e+00, -9.85410716e-01,
         3.45266027e+00,  1.56376928e-02,  5.27424947e-01,
        -2.58017367e+00, -2.34544641e+00,  8.51448321e-01,
        -6.64417574e-02, -3.17204624e+00, -1.60448330e+00,
         4.87718256e-01,  2.03572175e+00, -1.87365026e+00,
         3.12554540e-01, -1.03559520e+00,  2.60828651e-01,
        -1.13135153e+00,  1.25463236e+00, -1.43925684e+00]])], [array([[ 0.94832068],
       [-0.06266606],
       [-1.7593827 ],
       [-0.53870002],
       [-1.55386951],
       [-1.11558379],
       [ 0.02919313],
       [-0.28376287],
       [-0.54389668],
       [-2.50103053],
       [-0.08829055],
       [ 0.40428512],
       [-1.320014  ],
       [-0.59260049],
       [-0.77699536],
       [ 0.30419453],
       [ 0.33959821],
       [ 0.18065646],
       [ 0.55219802],
       [-0.02601865],
       [-0.01003154],
       [ 0.60856393],
       [ 1.6037076 ],
       [-1.37751807],
       [ 0.27298758],
       [ 1.74182634],
       [ 0.45654384],
       [ 1.63524933],
       [-0.93423304],
       [-2.03559187]]), array([[-0.11114176],
       [-1.92444931],
       [-3.65342767],
       [-0.78777011],
       [-2.12519832],
       [-0.08012127],
       [-1.61826407],
       [-1.28527636],
       [-2.07323325],
       [-2.96748178]])]]

and
newvalues:

[[array([[ 0.49047849, -0.49061768,  1.38129925, ...,  1.38365421,
        -2.84816588,  1.33435502],
       [ 0.14265502, -0.40701424, -0.06344381, ..., -0.04221331,
         1.87971909,  0.16228496],
       [ 1.25865165,  0.5694624 , -0.15033885, ..., -0.33268354,
         1.82849422, -0.32053569],
       ...,
       [-0.86875935, -1.31803218, -0.06188464, ...,  0.80358709,
        -1.22506318,  0.65488229],
       [ 0.72230337,  1.20813743,  0.70311973, ..., -1.31394859,
        -1.58026529,  1.573237  ],
       [ 0.75231614,  1.82261382,  0.28055294, ...,  0.63589566,
         1.54549887, -0.09006421]]), array([[ 9.04625312e-01, -1.20168740e+00, -2.05344286e+00,
         9.95282006e-01, -2.61128392e-01,  2.46883716e+00,
        -1.26605928e+00, -2.87461934e-01, -2.55345158e+00,
         3.95568507e+00,  6.47950996e-01,  2.92748875e-01,
        -1.90249337e+00, -2.05367861e+00,  1.17277862e+00,
         1.57364635e-01, -2.35467086e+00, -2.06776136e+00,
        -8.59204716e-02, -2.26256190e-01, -1.03518297e+00,
        -2.54459855e+00, -1.89909493e+00, -1.99529114e+00,
        -1.89778623e+00, -1.74062008e+00,  1.33135961e+00,
         1.66467987e-01,  3.65705086e-01,  1.15453112e+00],
       [ 5.18282670e-01,  2.10463982e+00,  2.22985297e-01,
         9.32875441e-02,  7.28948913e-01, -1.10041794e+00,
        -1.98894338e+00,  1.77096789e+00,  2.94633320e+00,
        -1.42998907e+00, -1.45059944e+00,  1.33818451e+00,
         2.37342106e+00, -2.77977954e+00, -2.89356946e+00,
         3.48555860e-01, -1.47593219e+00, -7.17198708e-01,
        -2.04548364e+00, -1.60860270e-02,  2.28442674e+00,
        -2.13940877e+00, -2.34960215e+00,  1.45710833e+00,
        -2.06243860e-02,  3.60329517e-01, -1.54618740e+00,
         2.19487096e+00, -1.04334123e-01, -2.94963266e+00],
       [-1.25268187e+00,  1.03468220e+00, -2.09360677e+00,
         2.72615924e+00,  8.03204286e-01, -1.21663915e+00,
        -3.14265961e+00, -2.99772834e-01, -6.55293117e-01,
        -1.85560311e+00, -1.69062463e-01,  1.53853932e-01,
         2.25068573e+00,  1.95227101e+00,  1.51207030e+00,
        -1.92508002e+00, -2.74164612e+00, -2.93852455e+00,
         2.01606172e+00, -6.91112599e-02, -2.27444607e+00,
        -2.75360145e+00, -1.62466484e-01,  1.68692850e+00,
         5.08041338e-01,  1.62613626e+00, -5.29857957e-02,
        -1.65836590e+00, -1.29237245e-03,  1.42649470e+00],
       [-1.00819993e+00,  2.63043465e+00, -8.48382777e-02,
        -4.38687260e-01,  3.76851240e-02,  5.60457581e-01,
        -1.86550332e+00, -4.34641085e-01, -3.02091630e+00,
        -1.55467958e+00,  7.91021890e-01,  1.23804246e+00,
         8.97229505e-01,  4.29841772e-01, -2.42525138e+00,
        -1.50064714e+00, -1.63826402e+00,  3.17469593e+00,
        -3.22054928e+00,  1.28392045e-01, -2.31741089e+00,
        -2.01552447e+00, -9.76992399e-01, -2.11558724e+00,
         1.92055199e+00,  5.55657968e-02, -1.75658363e+00,
        -2.46376324e+00,  1.73383489e+00,  1.56852876e+00],
       [-2.69408613e+00, -1.65159886e-01,  1.14444474e+00,
         1.23856668e+00,  1.02779879e+00,  2.81014023e+00,
         1.94193324e+00,  4.19896377e+00,  4.76766390e-01,
        -1.59098892e+00, -3.46217943e+00, -8.54517359e-01,
        -3.45234416e+00,  6.83242926e-01,  3.85724030e-02,
        -1.52278124e+00, -3.58015741e+00, -1.08273825e+00,
        -8.58495236e-02, -9.03825817e-01,  6.78730044e-01,
         5.18992143e-01,  3.42742226e+00, -1.52145368e+00,
         4.42189117e-01, -3.51066960e-01,  3.23080044e-01,
        -1.57079554e+00,  1.56477334e+00,  6.25506107e-01],
       [-3.33084155e-01, -2.79916035e+00,  5.22989199e-01,
         1.38178594e+00,  3.46671869e-01, -2.52869916e+00,
        -2.85003881e+00,  3.28334995e-01, -2.84497518e+00,
        -3.13336002e+00,  1.80758606e+00, -2.91602798e-01,
        -1.37399163e+00,  9.64047229e-01, -1.64202622e+00,
        -1.16234051e+00, -9.29535117e-01,  1.41014006e+00,
        -2.46834534e-01, -2.55373025e+00,  3.09016395e+00,
         1.98639570e+00,  1.10538587e+00,  4.80455892e-01,
        -1.63467864e+00,  7.28759567e-01,  2.64827251e+00,
         4.19659350e+00,  1.74234240e+00, -1.03982207e+00],
       [-1.99266677e+00, -3.45359895e+00, -1.66118838e+00,
        -6.86597421e-01, -3.64325347e-01,  2.37331770e+00,
         2.69295889e+00, -1.47113808e+00,  1.39082250e+00,
        -1.46233207e+00,  1.33042898e+00, -2.33113544e+00,
        -1.69593344e+00, -1.08305993e+00,  1.47304532e+00,
        -8.01031798e-01, -1.39920442e-01, -3.70400598e-01,
        -6.01091586e-01, -2.16153982e+00,  9.10587323e-01,
        -1.50354389e+00, -2.94728783e+00,  1.89153136e+00,
         1.43422568e+00, -6.14883762e-01, -1.29433499e+00,
         3.50730738e-01,  4.83855845e-03, -1.75349388e+00],
       [-1.65761588e+00, -5.63733247e-01,  4.25340960e-01,
         2.12352772e+00,  5.11942027e-01,  2.34213260e-01,
        -1.07488277e+00, -1.74688310e-01,  2.17174402e-02,
         2.48123976e-02, -3.62391678e-01,  6.56484593e-01,
         7.67530180e-01, -2.79774226e+00, -1.52769623e-01,
        -1.34026002e+00, -7.56261158e-01, -4.26031821e-01,
        -4.15734416e-01, -5.99522808e-01, -1.37719915e+00,
        -7.67536696e-01,  2.65846043e-01,  1.55756415e-01,
         6.99817419e-02,  5.52418194e-01, -3.16887735e+00,
         6.30433024e-01, -1.71636457e+00, -8.35886404e-01],
       [ 3.21696401e-01, -1.71443017e+00,  3.76632012e+00,
        -1.83856335e+00,  1.47475018e+00,  1.59866379e+00,
        -2.73854827e+00, -7.24335260e-02,  2.65913111e+00,
        -1.57314023e+00,  2.53103461e+00, -1.66971607e+00,
         9.40072925e-01,  9.69474126e-01, -1.69713625e+00,
        -9.04140008e-01, -2.44440263e+00, -5.97944024e-01,
         2.19066743e+00, -2.55224131e+00, -2.42208274e+00,
        -1.39494323e+00, -2.75270420e+00, -2.01258784e+00,
        -1.65333206e+00,  2.14839247e-01,  5.38008934e-01,
        -4.48039975e+00,  1.68560318e+00, -1.21934927e+00],
       [ 3.06599211e+00, -7.07372169e-01, -6.88577595e-01,
         6.59071311e-01, -2.00414045e+00,  4.02737209e+00,
         3.42991453e+00, -4.16059766e+00,  7.54238608e-03,
        -1.29674288e+00, -1.39663044e+00, -9.85410716e-01,
         3.45266027e+00,  1.56376928e-02,  5.27424947e-01,
        -2.58017367e+00, -2.34544641e+00,  8.51448321e-01,
        -6.64417574e-02, -3.17204624e+00, -1.60448330e+00,
         4.87718256e-01,  2.03572175e+00, -1.87365026e+00,
         3.12554540e-01, -1.03559520e+00,  2.60828651e-01,
        -1.13135153e+00,  1.25463236e+00, -1.43925684e+00]])], [array([[ 0.94832068],
       [-0.06266606],
       [-1.7593827 ],
       [-0.53870002],
       [-1.55386951],
       [-1.11558379],
       [ 0.02919313],
       [-0.28376287],
       [-0.54389668],
       [-2.50103053],
       [-0.08829055],
       [ 0.40428512],
       [-1.320014  ],
       [-0.59260049],
       [-0.77699536],
       [ 0.30419453],
       [ 0.33959821],
       [ 0.18065646],
       [ 0.55219802],
       [-0.02601865],
       [-0.01003154],
       [ 0.60856393],
       [ 1.6037076 ],
       [-1.37751807],
       [ 0.27298758],
       [ 1.74182634],
       [ 0.45654384],
       [ 1.63524933],
       [-0.93423304],
       [-2.03559187]]), array([[-0.11114176],
       [-1.92444931],
       [-3.65342767],
       [-0.78777011],
       [-2.12519832],
       [-0.08012127],
       [-1.61826407],
       [-1.28527636],
       [-2.07323325],
       [-2.96748178]])]]

11

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật