There are some useful tips for using Keras and Tensorflow to build models.

1. Using applications.inception_v3.InceptionV3(include_top = False, weights = ‘Imagenet’) to get pretrained parameters for InceptionV3 model, the console reported:

Exception: URL fetch failure on https://github.com/fchollet/deep-learning-models/releases/download/v0.5/inception_v3_weights_tf_dim_ordering_tf_kernels_notop.h5: None -- unknown url type: https

The solution is here. Just install some packages:

Sudo yum install openssl openssl-devel -y

2. Could we use ‘add’ to merge two DataFrames of Pandas? Let’s try

import pandas as pd
a = pd.DataFrame([[1, 2], [3, 4]], columns = ['first', 'second'])
b = pd.DataFrame([], columns = ['first', 'second'])
print(a+b)

The result is:

first second
0 NaN NaN
1 NaN NaN

The operator ‘+’ just works as ‘pandas.DataFrame.add‘. It try to add all values column by column, but the second DataFrame is empty, so the result of adding a number and a nonexistent value is ‘Nan’.

To merge two DataFrames, we should use ‘append’:

a.append(b)

3. Why Estimator of Tensorflow doesn’t print out log?

logging_hook = tf.train.LoggingTensorHook({'step': global_step, 'loss': loss, 'precision': precision, 'recall': recall, 'f1': f1, 'auc': auc},
every_n_iter = every_n_iter, formatter = formatter_log)
....
if mode == tf.estimator.ModeKeys.EVAL:
return tf.estimator.EstimatorSpec(mode, loss = loss, evaluation_hooks = [logging_hook])

But the logging_hook hasn’t been run. The solution is just adding one line before running Estimator:

tf.logging.set_verbosity(tf.logging.INFO)