This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Model(tf.keras.Model): | |
... | |
def __call__(self, inputs, training): | |
# Input layer | |
y = tf.reshape(inputs, self._input_shape) | |
y = self.conv1(y) | |
y = self.max_pool2d(y) | |
y = self.conv2(y) | |
y = self.max_pool2d(y) | |
y = tf.layers.flatten(y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def model_fn(features, labels, mode, params): | |
... | |
logits = model(image, training=False) | |
predictions = { | |
'classes': tf.argmax(logits, axis=1), | |
'probabilities': tf.nn.softmax(logits, name='softmax_tensor'), | |
} | |
if mode == tf.estimator.ModeKeys.PREDICT: | |
return tf.estimator.EstimatorSpec( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python official/mnist/mnist.py --export_dir /tmp/mnist_saved_model --model-dir /tmp/mnist_graph_def_with_ckpts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> ls /tmp/mnist_graph_def_with_ckpts | |
checkpoint | |
model.ckpt-48000 | |
model.ckpt-35626 | |
model.ckpt-39410 | |
model.ckpt-43218 | |
model.ckpt-47043 | |
model.ckpt-48000 | |
graph.pbtxt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From anywhere though I suggest you make it outside of the git repos | |
mkdir training_summaries | |
# Runs tensorboard in the background at http://localhost:6006 | |
tensorboard --logdir training_summaries & | |
# Using my modified import_pb_to_tensorboard.py in the tensorflow repo (feel free to edit to your liking) | |
import_pb_to_tensorboard.py --model_dir /tmp/mnist_graph_def_with_ckpts/graph.pbtxt --log_dir training_summaries/mnist --graph_type=PbTxt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
X = df_final.drop([‘fraud_reported_Y’,’policy_csl’,’policy_bind_date’,’incident_date’],axis=1).values | |
y = df_final[‘fraud_reported_Y’].values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
feats = [‘policy_state’,’insured_sex’,’insured_education_level’,’insured_occupation’,’insured_hobbies’,’insured_relationship’,’collision_type’,’incident_severity’,’authorities_contacted’,’incident_state’,’incident_city’,’incident_location’,’property_damage’,’police_report_available’,’auto_make’,’auto_model’,’fraud_reported’,’incident_type’] | |
df_final = pd.get_dummies(df,columns=feats,drop_first=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
classifier.compile(optimizer= ‘adam’,loss = ‘binary_crossentropy’,metrics = [‘accuracy’]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def make_classifier(): | |
classifier = Sequential() | |
classiifier.add(Dense(3, kernel_initializer = ‘uniform’, activation = ‘relu’, input_dim=5)) | |
classiifier.add(Dense(3, kernel_initializer = ‘uniform’, activation = ‘relu’)) | |
classifier.add(Dense(1, kernel_initializer = ‘uniform’, activation = ‘sigmoid’)) | |
classifier.compile(optimizer= ‘adam’,loss = ‘binary_crossentropy’,metrics = [‘accuracy’]) | |
return classifier |
OlderNewer