Skip to content

Instantly share code, notes, and snippets.

View yufengg's full-sized avatar
💭
Set status

Yufeng yufengg

💭
Set status
View GitHub Profile
feature_columns = [
tf.feature_column.numeric_column(
"pixels", shape=784)
]
classifier = tf.estimator.LinearClassifier(
feature_columns=feature_columns,
n_classes=10,
model_dir=logdir)
tf.estimator.inputs.numpy_input_fn(
x={'pixels': X},
y=Y,
batch_size=batch_size,
num_epochs=epochs,
shuffle=shuffle)
DATA_SETS = input_data.read_data_sets(
"/tmp/fashion-mnist")
classifier.train(
input_fn=train_input_fn,
steps=num_steps)
accuracy_score = classifier.evaluate(
input_fn=eval_input_fn)['accuracy']
classifier =
tf.estimator.DNNClassifier(
feature_columns=feature_columns,
n_classes=10,
hidden_units=[100, 75, 50],
model_dir=logdir
)
X = DATA_SETS.test.images[5000:5005]
predict_input_fn =
tf.estimator.inputs.numpy_input_fn(
x={'pixels': X},
batch_size=1,
num_epochs=1,
shuffle=False)
predictions = classifier.predict(
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yufengg
yufengg / AIA003_tf_estimators.ipynb
Last active April 5, 2020 00:42
Jupyter notebook for AI Adventures episode 3
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
// Corresponding spreadsheet: https://docs.google.com/spreadsheets/d/11pse2j9nLimlgyGsxVCtcHY7vBRYchMFslR_rIReNiQ/edit?usp=sharing
function myFunction(event) {
Logger.log(SpreadsheetApp.getActive().getUrl());
Logger.log(JSON.stringify(event));
row_num = event.range.rowStart;
col_num = event.range.columnEnd;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.