tensorflow

Bi-LSTM Attention model in Keras

我怕爱的太早我们不能终老 提交于 2021-02-07 09:15:42
问题 I am trying to make an attention model with Bi-LSTM using word embeddings. I came across How to add an attention mechanism in keras?, https://github.com/philipperemy/keras-attention-mechanism/blob/master/attention_lstm.py and https://github.com/keras-team/keras/issues/4962. However, I am confused about the implementation of Attention-Based Bidirectional Long Short-Term Memory Networks for Relation Classification . So, _input = Input(shape=[max_length], dtype='int32') # get the embedding layer

Tensorflow: what is the difference between tf.identity and '=' operator

女生的网名这么多〃 提交于 2021-02-07 08:57:18
问题 I'm confused about '=' operator, and tf.identity() , I thought '=' is to just make a reference of the tensor, and identity is to make a copy, e.g., with ref = x ref = ref*0 sess.run(x) I will get x all been set to 0 element-wise, and with copy = tf.identity(x) copy = ref*0 sess.run(x) x would not be changed, since identity make copy, not a reference, but with experiment, '=' also make a copy and x is not set to 0, so what's the difference? 回答1: The difference is only in tensorlfow graph

Use of Keras Sparse Categorical Crossentropy for pixel-wise multi-class classification

主宰稳场 提交于 2021-02-07 08:45:29
问题 I'll start by disclosing that I'm a machine learning and Keras novice and don't know much beyond general CNN binary classifiers. I'm trying to perform pixelwise multi-class classification using a U-Net architecture (TF backend) on many 256x256 images. In other words, I input a 256x256 image, and I want it to output a 256x256 "mask" (or label image) where the values are integers from 0-30 (each integer represents a unique class). I'm training on 2 1080Ti NVIDIA GPUs. When I attempt to perform

Use of Keras Sparse Categorical Crossentropy for pixel-wise multi-class classification

删除回忆录丶 提交于 2021-02-07 08:44:35
问题 I'll start by disclosing that I'm a machine learning and Keras novice and don't know much beyond general CNN binary classifiers. I'm trying to perform pixelwise multi-class classification using a U-Net architecture (TF backend) on many 256x256 images. In other words, I input a 256x256 image, and I want it to output a 256x256 "mask" (or label image) where the values are integers from 0-30 (each integer represents a unique class). I'm training on 2 1080Ti NVIDIA GPUs. When I attempt to perform

Can I installed tensorflow for python 2.7 and 3.5 on my machine simultaneously?

≯℡__Kan透↙ 提交于 2021-02-07 08:06:13
问题 Currently I have Python 2.7, Python 3.5, Tensorflow for Python 3.5 installed on my machine (MAC OX) via Anaconda. I would like to install Tensorflow for Python 2.7 on my machine as well. When I tried "conda create -n tensorflow python=2.7", I got the following error: " Error: prefix already exists: /Users/x644435/anaconda/envs/tensorflow ". It must be because I have already installed tensorflow for python 3.5. Can I installed tensorflow for python 2.7 and 3.5 on my machine simultaneously? And

Setting the hidden state for each minibatch with different hidden sizes and multiple LSTM layers in Keras

天大地大妈咪最大 提交于 2021-02-07 08:02:21
问题 I created an LSTM using Keras with TensorFlow as backend. Before a minibatch with a num_step of 96 is given to the training, the hidden state of the LSTM is set to true values of a previous time step. First the parameters and data: batch_size = 10 num_steps = 96 num_input = num_output = 2 hidden_size = 8 X_train = np.array(X_train).reshape(-1, num_steps, num_input) Y_train = np.array(Y_train).reshape(-1, num_steps, num_output) X_test = np.array(X_test).reshape(-1, num_steps, num_input) Y_test

Tensorflow 1.14 performance issue on rtx 3090

独自空忆成欢 提交于 2021-02-07 07:46:14
问题 I am running a model written with TensorFlow 1.x on 4x RTX 3090 and it is taking a long time to start up the training than as in 1x RTX 3090. Although, as training starts, it gets finished up earlier in 4x than in 1x. I am using CUDA 11.1 and TensorFlow 1.14 in both the GPUs. Secondly, When I am using 1x RTX 2080ti, with CUDA 10.2 and TensorFlow 1.14, it is taking less amount to start the training as compared to 1x RTX 3090 with 11.1 CUDA and Tensorflow 1.14. Tentatively, it is taking 5 min

Access deprecated attribute “validation_data” in tf.keras.callbacks.Callback

倖福魔咒の 提交于 2021-02-07 07:27:18
问题 I decided to switch from keras to tf.keras (as recommended here). Therefore I installed tf.__version__=2.0.0 and tf.keras.__version__=2.2.4-tf . In an older version of my code (using some older Tensorflow version tf.__version__=1.x.x ) I used a callback to compute custom metrics on the entire validation data at the end of each epoch. The idea to do so was taken from here. However, it seems as if the "validation_data" attribute is deprecated so that the following code is not working any longer

Inference error with TensorFlow C++ on iOS: “Invalid argument: Session was not created with a graph before Run()!”

我的未来我决定 提交于 2021-02-07 07:26:21
问题 I am trying to run my model on iOS using TensorFlow's C++ API. The model is a SavedModel saved as a .pb file. However, calls to Session::Run() result in the error: "Invalid argument: Session was not created with a graph before Run()!" In Python, I can successfully run inference on the model with the following code: with tf.Session() as sess: tf.saved_model.loader.load(sess, ['serve'], '/path/to/model/export') result = sess.run(['OutputTensorA:0', 'OutputTensorB:0'], feed_dict={ 'InputTensorA

Confusion about keras Model: __call__ vs. call vs. predict methods

流过昼夜 提交于 2021-02-07 07:21:34
问题 I have realized that I do not quite understand the difference between calling either the __call__ , call , or predict method of a Keras' model. For example, we have a trained keras model. After calling the code: # After training. y_pred_1 = model(X_new) y_pred_2 = model.call(X_new) y_pred_3 = model.predict(X_new) I expected that y_pred_1 , y_pred_2 , and y_pred_3 are all the same. But it turned out that they are not the same. Could you please explain to me the difference? 回答1: Just to