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:

1 |
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:

1 |
Sudo yum install openssl openssl-devel -y |

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

1 2 3 4 5 |
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:

1 2 3 |
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’:

1 |
a.append(b) |

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

1 2 3 4 5 |
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:

1 |
tf.logging.set_verbosity(tf.logging.INFO) |