tensorflow

tf.ones returns zeros instead of ones

两盒软妹~` 提交于 2021-02-10 15:41:21
问题 Why is tf.ones returning zeros? My version is '2.3.0' and I'm using an Anaconda environment. import tensorflow as tf tf.ones((3, 3)) <tf.Tensor: shape=(3, 3), dtype=float32, numpy= array([[0., 0., 0.], [0., 0., 0.], [0., 0., 0.]], dtype=float32)> I don't understand what's going on... But if I use dtype tf.int32 it works: tf.ones((3, 3), dtype=tf.int32) <tf.Tensor: shape=(3, 3), dtype=int32, numpy= array([[1, 1, 1], [1, 1, 1], [1, 1, 1]])> Someone here had the same issue. 回答1: Perhaps, your

Binary classification with softmax activation always outputs 1

核能气质少年 提交于 2021-02-10 15:16:58
问题 Sorry for the quality of the question but a beginner here , I was just trying my luck with titanic dataset, but it always predicts that the passenger died. I try to explain code below: import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sns import tensorflow as tf from tensorflow import keras from tensorflow.keras import layers from tensorflow.keras import losses from tensorflow.keras.layers.experimental import preprocessing import os Load dataset dataset

Binary classification with softmax activation always outputs 1

回眸只為那壹抹淺笑 提交于 2021-02-10 15:14:50
问题 Sorry for the quality of the question but a beginner here , I was just trying my luck with titanic dataset, but it always predicts that the passenger died. I try to explain code below: import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sns import tensorflow as tf from tensorflow import keras from tensorflow.keras import layers from tensorflow.keras import losses from tensorflow.keras.layers.experimental import preprocessing import os Load dataset dataset

Does tensorflow allow LSTM deconvolution ( convlstm2d) as it does for 2D convolution?

你说的曾经没有我的故事 提交于 2021-02-10 15:11:55
问题 I am trying to augment a network. For the convolution part, I am using convlstm2d from keras. Is there a process to perform deconvolution ( i.e. lstmdeconv2d ? ) 回答1: There is Conv3D for that, checkout this example used to predict the next frame 回答2: It should be possible to combine any model with the TimeDistributed wrapper. So you can create a deconv-model, and apply it on the output (which is a sequence of vectors) of the LSTM using the TimeDistributed wrapper. An example. First create a

Does tensorflow allow LSTM deconvolution ( convlstm2d) as it does for 2D convolution?

徘徊边缘 提交于 2021-02-10 15:02:13
问题 I am trying to augment a network. For the convolution part, I am using convlstm2d from keras. Is there a process to perform deconvolution ( i.e. lstmdeconv2d ? ) 回答1: There is Conv3D for that, checkout this example used to predict the next frame 回答2: It should be possible to combine any model with the TimeDistributed wrapper. So you can create a deconv-model, and apply it on the output (which is a sequence of vectors) of the LSTM using the TimeDistributed wrapper. An example. First create a

Tensorflow input dataset with varying size images

十年热恋 提交于 2021-02-10 14:53:17
问题 I'm trying to train a fully convolutional neural network using input images with different sizes. I can do this by looping over the training images and creating a single numpy input at each iteration i.e., for image_input, label in zip(image_data, labels): train_input_fn = tf.estimator.inputs.numpy_input_fn( x= {"x":image_input}, y=label, batch_size=1, num_epochs=None, shuffle=False) fcn_classifier.train(input_fn=input_func_gen, steps=1) However, in this way the model is saved and loaded

Limiting probability percentage of irrelevant image in CNN

时间秒杀一切 提交于 2021-02-10 14:51:40
问题 I am training a cnn model with five classes using keras library. Using model.predict function i get prediction percentage of the classes. My problem is for a image which doesn't belong to these classes and completely irrelevant, the predict class still predicts the percentages according to the classes. How do I prevent it? How do I identify it as irrelevant? 回答1: I assume you are using a softmax activation on your last layer to generate the probabilities for each class. By definition, the sum

ImportError: cannot import name 'context' from 'tensorflow.python.eager' (unknown location)

拈花ヽ惹草 提交于 2021-02-10 14:51:01
问题 I created virtual environment and installed both tensorflow and tensorflow-gpu. After that I installed keras. And then I checked in my conda terminal by importing keras and I was able to import keras in it. However, using jupyter notebook if I try to import keras then it gives me below error. import keras ImportError Traceback (most recent call last) <ipython-input-5-88d96843a926> in <module> ----> 1 import keras ~\Anaconda3\lib\site-packages\keras\__init__.py in <module> 1 from __future__

How to implement SegNet with preserving max-indexes in Keras

戏子无情 提交于 2021-02-10 14:42:00
问题 I'm trying to implement SegNet in Keras (tf backend) to do semantic segmentation. The most impressived trick of SgeNet is to pass max-pooling indices to the upsampling layers. However, there are many implementations of SegNet in Keras(e.g.) I find on github just using simple UpSampling (called SegNet-Basic). I notice that it can be achieved in Tensorflow with " tf.nn.max_pool_with_argmax ". So I want to know is there any similar method to get the max-pooling indices and put them back in

Resizing images with dynamic shape in tensorflow

孤人 提交于 2021-02-10 14:40:43
问题 I want to resize 3D images with a dynamic shape, for instance go from shape (64,64,64,1) to (128,128,128,1). The idea is to unstack the image along one axis, then use tf.image.resize_images and stack them again. My issue is that tf.unstack can not handle variable sized inputs. If I run my code I obtain "ValueError: Cannot infer num from shape (?, ?, ?, 1)" I have considered using tf.split instead, however it expects an integer input. Does anybody know a workaround? Here is an example: import