tensorflow

Tensorboard Image Summaries

徘徊边缘 提交于 2021-02-19 03:43:48
问题 I use Matplotlib to create custom t-SNE embedding plots at each epoch during trainging. I would like the plots to be displayed on Tensorboard in a slider format, like this MNST example: But instead each batch of plots is displayed as separate summaries per epoch, which is really hard to review later. See below: It appears to be creating multiple image summaries with the same name, so appending _X suffix instead of overwriting or adding to slider like I want. Similarly, when I use the family

Adapting Tensorflow RNN Seq2Seq model code for Tensorflow 2.0

£可爱£侵袭症+ 提交于 2021-02-19 03:00:15
问题 I am very new to Tensorflow and have been messing around with a simple chatbot-building project from this link. There were many warnings that were saying that things would be deprecated in Tensorflow 2.0 and that I should upgrade, so I did. I then used the automatic Tensorflow code upgrader to update all the necessary files to 2.0. There were a few errors with this. When processing the model.py file, it returned these warnings: 133:20: WARNING: tf.nn.sampled_softmax_loss requires manual check

Discrepancy between R's Keras and Python's Keras — Accuracy bug?

我们两清 提交于 2021-02-19 02:31:20
问题 I'm playing with some 2D CNN using Keras to predict Bike Sharing Demand. R performs very poorly vs Python, which reach good accuracy easily. I thought it was because of arrays shape (and some differences between R and Python), so I play with that for a while, ultimately using all possible shapes. I created the CombinationGrid object elsewhere and it looks like this: +------+------+------+------+-------+ | Dim1 | Dim2 | Dim3 | Dim4 | Order | +------+------+------+------+-------+ | 8887 | 3 | 2

tf.keras: Evaluating model.updates breaks when using a tf.data.Dataset as input

别来无恙 提交于 2021-02-19 02:01:09
问题 Note: All code for a self-contained example to reproduce my problem can be found below. I have a tf.keras.models.Model() instance and would like to train that with a custom low-level TensorFlow API training loop. As part of this training loop, I need to make sure that my custom training loop updates all stateful variables from layer types such as tf.keras.layers.BatchNormalization . In order for this to happen, I understand from this answer by Francois Chollet that I need to evaluate model

Keras TypeError: can't pickle _thread.RLock objects

巧了我就是萌 提交于 2021-02-19 01:48:23
问题 from keras.layers import Embedding, Dense, Input, Dropout, Reshape from keras.layers.convolutional import Conv2D from keras.layers.pooling import MaxPool2D from keras.layers import Concatenate, Lambda from keras.backend import expand_dims from keras.models import Model from keras.initializers import constant, random_uniform, TruncatedNormal class TextCNN(object): def __init__( self, sequence_length, num_classes, vocab_size, embedding_size, filter_sizes, num_filters, l2_reg_lambda=0.0): #

Train multiple keras/tensorflow models on different GPUs simultaneously

有些话、适合烂在心里 提交于 2021-02-19 01:42:07
问题 I would like to train multiple models on multiple GPUs at the simultaneously from within a jupyter notebook. I am working on a node with 4GPUs. I would like to assign one GPU to one model and train 4 different models at the same time. Right now, I select a GPU for one notebook by (e.g.): import os os.environ['CUDA_VISIBLE_DEVICES'] = '1' def model(...): .... model.fit(...) In four different notebooks. Though, then the results and the output of the fitting procedure is distributed in four

How to fetch specific rows from a tensor in Tensorflow?

倾然丶 夕夏残阳落幕 提交于 2021-02-19 01:30:09
问题 I have a tensor defined as follows: temp_var = tf.Variable(initial_value=np.asarray([[1, 2, 3],[4, 5, 6],[7, 8, 9],[10, 11, 12]])) I also have an array of indexes of rows to be fetched from tensor: idx = tf.constant([0, 2]) Now I want to take a subset of temp_var at those indexes i.e. idx I know that to take a single index or a slice, we can do something like temp_var[single_row_index, :] or temp_var[start:end, :] But how to fetch rows indicated by idx array? Something like temp_var[idx, :] ?

How to fetch specific rows from a tensor in Tensorflow?

狂风中的少年 提交于 2021-02-19 01:29:06
问题 I have a tensor defined as follows: temp_var = tf.Variable(initial_value=np.asarray([[1, 2, 3],[4, 5, 6],[7, 8, 9],[10, 11, 12]])) I also have an array of indexes of rows to be fetched from tensor: idx = tf.constant([0, 2]) Now I want to take a subset of temp_var at those indexes i.e. idx I know that to take a single index or a slice, we can do something like temp_var[single_row_index, :] or temp_var[start:end, :] But how to fetch rows indicated by idx array? Something like temp_var[idx, :] ?

ValueError: Shape mismatch: The shape of labels (received (15,)) should equal the shape of logits except for the last dimension (received (5, 3))

*爱你&永不变心* 提交于 2021-02-18 23:26:25
问题 I am getting this error when trying to fit a model: ValueError: Shape mismatch: The shape of labels (received (15,)) should equal the shape of logits except for the last dimension (received (5, 3)). The code that's producing the error: history = model.fit_generator( train_generator, epochs=10, validation_data=validation_generator) This is the train_generator, validation generator is similar: train_datagen = ImageDataGenerator(rescale=1./255) train_generator = train_datagen.flow_from_directory

Keras Embedding ,where is the “weights” argument?

感情迁移 提交于 2021-02-18 22:33:28
问题 I have seen such kind of code as follow: embed_word = Embedding(params['word_voc_size'], params['embed_dim'], weights=[word_embed_matrix], input_length = params['word_max_size'] , trainable=False, mask_zero=True) When I look up the document in Keras website [https://faroit.github.io/keras-docs/2.1.5/layers/embeddings/][1] I didnt see weights argument, keras.layers.Embedding(input_dim, output_dim, embeddings_initializer='uniform', embeddings_regularizer=None, activity_regularizer=None,