We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This code (k-fold cross val) misses a parenthesis on np.concatenate:
'''k = 3 num_validation_samples = len(data) // k np.random.shuffle(data) validation_scores = [] for fold in range(k): validation_data = data[num_validation_samples * fold: ❶ num_validation_samples * (fold + 1)] ❶ training_data = np.concatenate( ❷ data[:num_validation_samples * fold], ❷ data[num_validation_samples * (fold + 1):]) ❷ model = get_model() ❸ model.fit(training_data, ...) validation_score = model.evaluate(validation_data, ...) validation_scores.append(validation_score) validation_score = np.average(validation_scores) ❹ model = get_model() ❺ model.fit(data, ...) ❺ test_score = model.evaluate(test_data, ...) '''
The previous code (held out validation) was correct, the k-fold code misses a "(" and ")", the correct code should look like:
'''training_data = np.concatenate( ( ❷ data[:num_validation_samples * fold], ❷ data[num_validation_samples * (fold + 1):]) ) ❷'''
As documentation for np.concatenate states:
'''a = np.array([[1, 2], [3, 4]]) b = np.array([[5, 6]]) p.concatenate((a, b), axis=None)'''
Kind regards
The text was updated successfully, but these errors were encountered:
Sorry, something went wrong.
Also would be great to make clear on the code too that it is supressing the k-fold for the labels
No branches or pull requests
This code (k-fold cross val) misses a parenthesis on np.concatenate:
'''k = 3
num_validation_samples = len(data) // k
np.random.shuffle(data)
validation_scores = []
for fold in range(k):
validation_data = data[num_validation_samples * fold: ❶
num_validation_samples * (fold + 1)] ❶
training_data = np.concatenate( ❷
data[:num_validation_samples * fold], ❷
data[num_validation_samples * (fold + 1):]) ❷
model = get_model() ❸
model.fit(training_data, ...)
validation_score = model.evaluate(validation_data, ...)
validation_scores.append(validation_score)
validation_score = np.average(validation_scores) ❹
model = get_model() ❺
model.fit(data, ...) ❺
test_score = model.evaluate(test_data, ...) '''
The previous code (held out validation) was correct, the k-fold code misses a "(" and ")", the correct code should look like:
'''training_data = np.concatenate( ( ❷
data[:num_validation_samples * fold], ❷
data[num_validation_samples * (fold + 1):]) ) ❷'''
As documentation for np.concatenate states:
'''a = np.array([[1, 2], [3, 4]])
b = np.array([[5, 6]])
p.concatenate((a, b), axis=None)'''
Kind regards
The text was updated successfully, but these errors were encountered: