Could not broadcast input array from shape (1688) into shape (2)?

Hello I’m new to python so I was thinking on building a simple neural network…I think I’m almost there and got an error, so I would really need a help right now.

from PIL import Image
from scipy.misc import imread
import matplotlib.pyplot as plt
import matplotlib.image as mpimg

from pybrain.tools.shortcuts import buildNetwork
from pybrain.datasets import SupervisedDataSet
from pybrain.supervised.trainers import BackpropTrainer
from scipy import misc

with open("a.png", "rb") as imageFile:
  f = imageFile.read()
  b = bytearray(f)

neuralNetwork = buildNetwork(2,3,1)
dataSet = SupervisedDataSet(2,1)

dataSet.addSample((b),(0,))
trainer = BackpropTrainer (neuralNetwork, dataSet)

error = 10
iteration = 0

 for i in range (1,10000):
        trainer.train()
        if (i % 1000 == 0):
            print(i)
            print(dataSet.activate((b),(0,)) )

print(dataSet.activate((b),(0,)) )

Any help will do, thanks :banghead:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.