# Buggy code
def _initialize(self, y, layer_units):
    # set all attributes, allocate weights etc for first call
    # Initialize parameters
    self.n_iter_ = 0
    self.t_ = 0
    self.n_outputs_ = y.shape[1]

    # Compute the number of layers
    self.n_layers_ = len(layer_units)

    # Output for regression
    if not isinstance(self, ClassifierMixin):
        self.out_activation_ = "identity"
    # Output for multi class
    elif self.label_binarizer_.y_type_ == "multiclass":
        self.out_activation_ = "softmax"
    # Output for binary class and multi-label
    else:
        self.out_activation_ = "logistic"

    # Initialize coefficient and intercept layers
    self.coefs_ = []
    self.intercepts_ = []

    for i in range(self.n_layers_ - 1):
        coef_init, intercept_init = self._init_coef(layer_units[i], layer_units[i + 1])
        self.coefs_.append(coef_init)
        self.intercepts_.append(intercept_init)

    if self.solver in _STOCHASTIC_SOLVERS:
        self.loss_curve_ = []
        self._no_improvement_count = 0
        if self.early_stopping:
            self.validation_scores_ = []
            self.best_validation_score_ = -np.inf
        else:
            self.best_loss_ = np.inf


# Traceback (ValueError)
Traceback (most recent call last):
File "fail.py", line 7, in <module>
clf.partial_fit([[4]],["d"])
File "/usr/local/lib/python3.4/dist-packages/sklearn/neural_network/multilayer_perceptron.py", line 989, in _partial_fit
super(MLPClassifier, self)._partial_fit(X, y)
File "/usr/local/lib/python3.4/dist-packages/sklearn/neural_network/multilayer_perceptron.py", line 640, in _partial_fit
return self._fit(X, y, incremental=True)
File "/usr/local/lib/python3.4/dist-packages/sklearn/neural_network/multilayer_perceptron.py", line 375, in _fit
intercept_grads, layer_units, incremental)
File "/usr/local/lib/python3.4/dist-packages/sklearn/neural_network/multilayer_perceptron.py", line 512, in _fit_stochastic
coef_grads, intercept_grads)
File "/usr/local/lib/python3.4/dist-packages/sklearn/neural_network/multilayer_perceptron.py", line 225, in _backprop
loss = LOSS_FUNCTIONS[self.loss](y, activations[-1])
File "/usr/local/lib/python3.4/dist-packages/sklearn/neural_network/_base.py", line 208, in log_loss
return -np.sum(y_true * np.log(y_prob)) / y_prob.shape[0]
ValueError: operands could not be broadcast together with shapes (1,2) (1,3)

# Fixed code
def _initialize(self, y, layer_units):
    # set all attributes, allocate weights etc for first call
    # Initialize parameters
    self.n_iter_ = 0
    self.t_ = 0
    self.n_outputs_ = y.shape[1]

    # Compute the number of layers
    self.n_layers_ = len(layer_units)

    # Output for regression
    if not isinstance(self, ClassifierMixin):
        self.out_activation_ = "identity"
    # Output for multi class
    elif self._label_binarizer.y_type_ == "multiclass":
        self.out_activation_ = "softmax"
    # Output for binary class and multi-label
    else:
        self.out_activation_ = "logistic"

    # Initialize coefficient and intercept layers
    self.coefs_ = []
    self.intercepts_ = []

    for i in range(self.n_layers_ - 1):
        coef_init, intercept_init = self._init_coef(layer_units[i], layer_units[i + 1])
        self.coefs_.append(coef_init)
        self.intercepts_.append(intercept_init)

    if self.solver in _STOCHASTIC_SOLVERS:
        self.loss_curve_ = []
        self._no_improvement_count = 0
        if self.early_stopping:
            self.validation_scores_ = []
            self.best_validation_score_ = -np.inf
        else:
            self.best_loss_ = np.inf