Weights in AI determine how much influence the input is going to have on the output. In neural networks, algorithms use weights to process the information and train the model. The output is expected to be the same as the target attributes.
However, the output may have some errors, which need to be rectified to produce the exact output. For example, in the Backpropagation algorithm when there is an error in the output, the algorithm will backpropagate to the hidden layer and reroute the weights to get an optimized output.