deep-learning

TypeError: 'float' object cannot be interpreted as an index

廉价感情. 提交于 2020-02-01 05:44:05
问题 I am facing an issue which was not occurring before, maybe some rules have been changed. Traceback (most recent call last) <ipython-input-3-f47687e192a7> in <module>() 5 n_examples = X.shape[0] 6 n_train = n_examples * 0.5 ----> 7 train_idx = np.random.choice(range(0,n_examples), size=n_train, replace=False) 8 test_idx = list(set(range(0,n_examples))-set(train_idx)) 9 X_train = X[train_idx] mtrand.pyx in mtrand.RandomState.choice (numpy/random/mtrand/mtrand.c:18822)() TypeError: 'float'

Adding an additional value to a Convolutional Neural Network Input? [closed]

喜夏-厌秋 提交于 2020-02-01 05:20:06
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . I have a dataset of images I want to input to a Convolutional Neural Network Model, however, with each of these images, there is a range or distance from the object associated with the image. I want to input this range as an additional piece of context for the CNN model. Does

Keras Multi-inputs AttributeError: 'NoneType' object has no attribute 'inbound_nodes'

房东的猫 提交于 2020-02-01 03:27:30
问题 I'm trying to build a model as ilustrated in below diagram. The idea is to take more than one categorical features (one-hot vectors) and embed them separately, then combine those embedded vectors with a 3D tensor for a LSTM. With following code in Keras2.0.2 , when creating the Model() object with multiple inputs, it raises an AttributeError: 'NoneType' object has no attribute 'inbound_nodes' similar to this question. Can anyone help me to figure out what's the problem? Model: Code: from

Custom loss function in Keras to penalize false negatives

[亡魂溺海] 提交于 2020-02-01 02:22:47
问题 I am working on a medical dataset where I am trying to have as less false negatives as possible. A prediction of "disease when actually no disease" is okay for me but a prediction "no disease when actually a disease" is not. That is, I am okay with FP but not FN . After doing some research, I found out ways like Keeping higher learning rate for one class , using class weights , ensemble learning with specificity/sensitivity etc. I achieved the near desired result using class weights like

How to calculate batch normalization with python?

梦想的初衷 提交于 2020-01-30 10:55:06
问题 When I implement batch normalization in python from scrach, I am confused. Please see A paper demonstrates some figures about normalization methods, I think it may be not correct. The description and figure are both not correct. Description from the paper: Figure from the paper: As far as I am concerned, the representation of batch normalization is not correct in the original paper. I post the issue here for discussion. I think the batch normalization should be like the following figure. The

tf.Estimator.train throws as_list() is not defined on an unknown TensorShape

牧云@^-^@ 提交于 2020-01-30 06:58:48
问题 I created a custom input_func and converted a keras model into tf.Estimator for training. However, it keeps throwing me error. Here is my model summary. I have attempted to set the Input layer with batch_shape=(16, 320, 320, 3) for testing but the problem still persits inputs = Input(batch_shape=(16, 320, 320, 3), name='input_images') outputs = yolov2.predict(intputs) model = Model(inputs, outputs) model.compile(optimizer= tf.keras.optimizers.Adam(lr=learning_rate), loss = compute_loss) I

How to load a heavy model when using MVC design pattern

心已入冬 提交于 2020-01-30 03:45:15
问题 I'm building an application with wxPython and a Deep Learning model that I created using Tensorflow. The design pattern that I'm using is MVC. My problem is that the deep learning model is very heavy and it takes a very long time to load (like ~2 minutes) and in the meantime the GUI hangs. I created a sample code that describes the process. Here is what the GUI looks like while loading: enter image description here and this is what the GUI looks like after the loading: enter image description

how to calculate a Mobilenet FLOPs in Keras

与世无争的帅哥 提交于 2020-01-29 21:06:06
问题 run_meta = tf.RunMetadata() enter codwith tf.Session(graph=tf.Graph()) as sess: K.set_session(sess) with tf.device('/cpu:0'): base_model = MobileNet(alpha=1, weights=None, input_tensor=tf.placeholder('float32', shape=(1,224,224,3))) opts = tf.profiler.ProfileOptionBuilder.float_operation() flops = tf.profiler.profile(sess.graph, run_meta=run_meta, cmd='op', options=opts) opts = tf.profiler.ProfileOptionBuilder.trainable_variables_parameter() params = tf.profiler.profile(sess.graph, run_meta

how to calculate a Mobilenet FLOPs in Keras

陌路散爱 提交于 2020-01-29 21:05:06
问题 run_meta = tf.RunMetadata() enter codwith tf.Session(graph=tf.Graph()) as sess: K.set_session(sess) with tf.device('/cpu:0'): base_model = MobileNet(alpha=1, weights=None, input_tensor=tf.placeholder('float32', shape=(1,224,224,3))) opts = tf.profiler.ProfileOptionBuilder.float_operation() flops = tf.profiler.profile(sess.graph, run_meta=run_meta, cmd='op', options=opts) opts = tf.profiler.ProfileOptionBuilder.trainable_variables_parameter() params = tf.profiler.profile(sess.graph, run_meta

Tensorflow Estimator - Periodic Evaluation on Eval Dataset

大憨熊 提交于 2020-01-29 05:30:05
问题 The tensorflow documentation does not provide any example of how to perform a periodic evaluation of the model on an evaluation set. Some people suggested the use of an Experiment, which sounds great but unfortunately does not work (depreciation and triggers an error). Others suggested the use of SummarySaverHook, but I don't see how you can use that with an evaluation set (as opposed to the training set). A solution would be to do the following for i in range(number_of_epoch): estimator