keras-2

Use “Flatten” or “Reshape” to get 1D output of unknown input shape in keras

我怕爱的太早我们不能终老 提交于 2019-11-29 22:40:18
问题 I want to use the keras layer Flatten() or Reshape((-1,)) at the end of my model to output an 1D vector like [0,0,1,0,0, ... ,0,0,1,0] . Sadly there is an problem because of my unknown input shape which is: input_shape=(4, None, 1))) . So typically the input shape is something between [batch_size, 4, 64, 1] and [batch_size, 4, 256, 1] the output should be batch_size x unknown dimension (for the fist example above: [batch_size, 64] and for the secound [batch_size, 256] ). My model looks like:

ImportError: cannot import name '_obtain_input_shape' from keras

六眼飞鱼酱① 提交于 2019-11-29 03:08:21
In Keras, I'm trying to import _obtain_input_shape as follows: from keras.applications.imagenet_utils import _obtain_input_shape However, I get the following error: ImportError: cannot import name '_obtain_input_shape' The reason I'm trying to import _obtain_input_shape is so that I can determine the input shape(so as to load VGG-Face as follows : I'm using it to determine the correct input shape of the input tensor as follow: input_shape = _obtain_input_shape(input_shape, default_size=224, min_size=48, data_format=K.image_data_format(), require_flatten=include_top)` Please assist? Thanks in

Keras: Add variables to progress bar

蓝咒 提交于 2019-11-28 19:21:25
问题 I'd like to monitor eg. the learning rate during training in Keras both in the progress bar and in Tensorboard. I figure there must be a way to specify which variables are logged, but there's no immediate clarification on this issue on the Keras website. I guess it's got something to do with creating a custom Callback function, however, it should be possible to modify the already existing progress bar callback, no? 回答1: It can be achieved via a custom metric. Take the learning rate as an

How to use TensorFlow metrics in Keras

爷,独闯天下 提交于 2019-11-27 14:46:39
There seem to be several threads/issues on this already but it doesn't appear to me that this has been solved: How can I use tensorflow metric function within keras models? https://github.com/fchollet/keras/issues/6050 https://github.com/fchollet/keras/issues/3230 People seem to either run into problems around variable initialization or the metric being 0. I need to calculate different segmentation metrics and would like to include tf.metric.mean_iou in my Keras model. This is the best I have been able to come up with so far: def mean_iou(y_true, y_pred): score, up_opt = tf.metrics.mean_iou(y

How to use TensorFlow metrics in Keras

 ̄綄美尐妖づ 提交于 2019-11-26 16:54:07
问题 There seem to be several threads/issues on this already but it doesn't appear to me that this has been solved: How can I use tensorflow metric function within keras models? https://github.com/fchollet/keras/issues/6050 https://github.com/fchollet/keras/issues/3230 People seem to either run into problems around variable initialization or the metric being 0. I need to calculate different segmentation metrics and would like to include tf.metric.mean_iou in my Keras model. This is the best I have