Cannot manipulate lists
<p>I am new to python and trying to integrate a sample from my problem domain in python and getting the following error:</p>

<pre><code>sum_square_error += (output[0:1] - expected) ** 2
TypeError: unsupported operand type(s) for -: 'list' and 'list'
</code></pre>

<p>The program:</p>

<pre><code>from __future__ import print_function

import os
import numpy as np
import sys as sys

from neat import nn, population, statistics

# Network inputs and expected outputs.
#xor_inputs = [[0.0, 0.0], [0.0, 1.0], [1.0, 0.0], [1.0, 1.0]]
#xor_outputs = [0.0, 1.0, 1.0, 0.0]

xor_inputs = [[-14.7569, 17.9667, -55.0074, -0.218445, 0.835469, 11.23]]

''',
              [-23.8745,7.40331,-48.5434,0.114681,-0.0208769,15.2138],
              [-22.2368,7.02313,-54.734,0.0633238,-0.097209,12.7707],
              [-19.0957,7.03371,-48.6117,0.108994,-0.0357287,15.205]]
'''

xor_outputs = [[-31.1812, 47.2076, -34.9315, 62.6799]]
''',
               [-53.9514,97.2412,55.7927,92.506],
               [-27.417,47.7492,-28.1557,78.6016],
               [-57.4506,99.2558,55.7436,92.3611]]
'''


def eval_fitness(genomes):
    for g in genomes:
        net = nn.create_feed_forward_phenotype(g)

        sum_square_error = 0.0
        for inputs, expected in zip(xor_inputs, xor_outputs):
            # Serial activation propagates the inputs through the entire network.
            output = net.serial_activate(inputs)
#            print(xor_inputs[0:1])
#            print(xor_outputs[0:1])
#            sys.exit(0)
            sum_square_error += (output[0] - expected) ** 2

        # When the output matches expected for all inputs, fitness will reach
        # its maximum value of 1.0.
        g.fitness = 1 - sum_square_error


local_dir = os.path.dirname(__file__)
config_path = os.path.join(local_dir, 'xor2_config')
pop = population.Population(config_path)
pop.run(eval_fitness, 300)

# Log statistics.
statistics.save_stats(pop.statistics)
statistics.save_species_count(pop.statistics)
statistics.save_species_fitness(pop.statistics)

print('Number of evaluations: {0}'.format(pop.total_evaluations))

# Show output of the most fit genome against training data.
winner = pop.statistics.best_genome()
print('\nBest genome:\n{!s}'.format(winner))
print('\nOutput:')
winner_net = nn.create_feed_forward_phenotype(winner)
for inputs, expected in zip(xor_inputs, xor_outputs):
    output = winner_net.serial_activate(inputs)
    print("expected {0:1.5f} got {1:1.5f}".format(expected, output[0]))
</code></pre>

<p>I have searched the error and found that it needs to be converted into numpy array. When i convert the xor_inputs and xor_outputs to numpy arrays then it says:</p>

<pre><code>ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
</code></pre>

<p>It should be noted that the initial problem of xor has 2 inputs in 2d array and 1 output in the 1d output array. In my problem i have 6 inputs in 2d array and 4 outputs in 2d output array.</p>