tensorflow

neural network: Why is my code not reproducible?

牧云@^-^@ 提交于 2021-01-29 16:15:49
问题 I thought my neural network would be reproducible, but it is not! The results are not dramatically different but for example the loss is about 0.1 different from one run. So here is my Code! # Code reproduzierbar machen from numpy.random import seed seed(0) from tensorflow import set_random_seed set_random_seed(0) # Importiere Datasets (Training und Test) import pandas as pd poker_train = pd.read_csv("C:/Users/elihe/Documents/Studium Master/WS 19 und 20/Softwareprojekt/poker-hand-training

how to call opencv functions in tensorflow(python)?

那年仲夏 提交于 2021-01-29 15:13:32
问题 when I train the model,I have customized a loss function.The calculation of the loss value in this function requires the function of opencv.See the code,but I get a wrong.I don't know how to solve it,someone can help me?Thanks a lot. #this is my loss function def instance_loss_function(predict,label): best_match_label_image=search_MaxPixelAccuracy_permutation(predict_convert_gray_image(predict),label) predict_image=predict loss_sum=0.0 best_match_label_image_contours_number=len(cv2

Lambda layer to perform if then in keras/tensorflow

﹥>﹥吖頭↗ 提交于 2021-01-29 14:47:02
问题 I'm tearing my hair out with this one. I asked a question over here If then inside custom non-trainable keras layer but I'm still having difficulties. I tried his solution, but it didn't work - I thought I'd post my complete code with his solution I have a custom Keras layer that I want to return specific output from specific inputs. I don't want it to be trainable. The layer should do the following if input = [1,0] then output = 1 if input = [0,1] then output = 0 Here's the lambda layer code

Error while installing tensorflow(AVX support) and cpuid python

妖精的绣舞 提交于 2021-01-29 14:31:30
问题 While I was trying to setup tensorflow (both, using venv and without it) on import I got the following error: ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed. I went to the official site's error page and found that possibly AVX and AVX2 instructions set support could be the issue, to check it, it was suggested to run this code: from cpuid import * def _is_set(id, reg_idx, bit): regs = cpuid(id) if (1 << bit) & regs[reg_idx]: return "Yes" else: return "

How do I make tensorflow evaluate tensors in parallel?

随声附和 提交于 2021-01-29 14:15:30
问题 From my understanding tensorflow makes a computational graph and then when I run the session it evaluates this graph and does what it can in parallel. How do I as a user make sure/check that tensorflow is doing stuff in parallel? Suppose I have the following code: x = tf.placeholder() y = x**2 + 123 z = 5*x/(x+2) res = y+z When I evaluate res, is y and z calculated in parallel? Also, from my testing it appears that building the graph inside a for loop breaks something because when I've tried

How to produce a variable size distance matrix in keras?

旧时模样 提交于 2021-01-29 14:13:11
问题 What I am trying to achieve now is to create a custom loss function in Keras that takes in two tensors (y_true, y_pred) with shapes (None, None, None) and (None, None, 3) , respectively. However, the None 's are so, that the two shapes are always equal for every (y_true, y_pred) . From these tensors I want to produce two distance matrices that contain the squared distances between every possible point pair (the third, length 3 dimension contains x, y, and z spatial values) inside them and

ValueError: Input 0 of layer cu_dnnlstm is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: [None, 175]

核能气质少年 提交于 2021-01-29 13:58:06
问题 I am experimenting with CuDNNLSTMs and, i dont know why, even though i am following a tutorial on this, i get this weird error, that i can understand, but i can't debug: So i have a 4073 time-series * 175 features array and i am trying to pass those 175 features to the Sequential model, one at a time, to a CuDNNLSTM layer, in order for the model to learn something from it. "AlvoH" is the target of the RNN. The code: train_x, train_y = trainDF, trainDF["AlvoH"] validation_x, validation_y =

Output score/probability for all class for each object with Tensorflow object detection API

亡梦爱人 提交于 2021-01-29 13:27:10
问题 in Tensorflow object detection API, we usually do this for each test image: output_dict = sess.run(tensor_dict, feed_dict={image_tensor: image_np_expanded}) # pdb.set_trace() # all outputs are float32 numpy arrays, so convert types as appropriate output_dict['num_detections'] = int(output_dict['num_detections'][0]) output_dict['detection_classes'] = output_dict['detection_classes'][0].astype(np.int64) output_dict['detection_boxes'] = output_dict['detection_boxes'][0] output_dict['detection

Tensor(“args_0:0”, shape=(28, 28, 1), dtype=float32)

我是研究僧i 提交于 2021-01-29 13:20:15
问题 I was trying to execute the code below in Google Colab for learning purposes.I got this message when i executed the following code. Tensor("args_0:0", shape=(28, 28, 1), dtype=float32) def normalize(images, labels): print(images) images = tf.cast(images, tf.float32) print(images) images /= 255 print(images) return images, labels I am trying to understand what this message means but I am not able ti understand it. Tried searching in web , but couldn't find much resources. Can anyone say what

TensorFlow2-tf.keras: Loss and model weights suddenly become 'nan' when training MTCNN PNet

心已入冬 提交于 2021-01-29 12:59:14
问题 I was trying to use tfrecords to train the PNet of MTCNN. At first the loss was decreasing smoothly for the first few epochs and then it became 'nan' and so did the model weights. Below are my model structure and training results: def pnet_train1(train_with_landmark = False): X = Input(shape = (12, 12, 3), name = 'Pnet_input') M = Conv2D(10, 3, strides = 1, padding = 'valid', kernel_initializer = glorot_normal, kernel_regularizer = l2(0.00001), name = 'Pnet_conv1')(X) M = PReLU(shared_axes =