keras

Accuracy given from evaluating model not equal to sklearn classification_report accuracy

狂风中的少年 提交于 2021-01-19 08:08:17
问题 I'm using sklearn classification_report for reporting test statistics. The accuracy given by this method is 42% while model evaluation gives 93% accuracy. Which one is the real accuracy and what's the reason of this difference? Model evaluation: results = model.evaluate(test_ds.values, test_lb.values) print(results) Output: 7397/7397 [==============================] - 0s 28us/sample - loss: 0.2309 - acc: 0.9305 Report Classification: import numpy as np from sklearn.metrics import

Difference between .pb and .h5

試著忘記壹切 提交于 2021-01-19 05:33:47
问题 What is the main difference between . pb format of tensorflow and .h5 format of keras to store models? Is there any reason to choose one over the other? 回答1: Different file formats with different characteristics, both used by tensorflow to save models ( .h5 specifically by keras ). .pb - protobuf It is a way to store some structured data (in this case a neural network),project is open source and currently overviewed by Google. Example person { name: "John Doe" email: "jdoe@example.com" }

Keras custom data generator giving dimension errors with multi input and multi output( functional api model)

夙愿已清 提交于 2021-01-18 04:53:32
问题 I have written a generator function with Keras, before returning X,y from __getitem__ I have double check the shapes of the X's and Y's and they are alright, but generator is giving dimension mismatch array and warnings. (Colab Code to reproduce: https://colab.research.google.com/drive/1bSJm44MMDCWDU8IrG2GXKBvXNHCuY70G?usp=sharing) My training and validation generators are pretty much same as class ValidGenerator(Sequence): def __init__(self, df, batch_size=64): self.batch_size = batch_size

ValueError: Error when checking target: expected dense_2 to have shape (1,) but got array with shape (14,)

自闭症网瘾萝莉.ら 提交于 2021-01-18 04:41:14
问题 I am trying to train a classification model in a distributed way. I am using TensorflowOnSpark library developed by Yahoo. The example I am using github link I am using dataset other than mnist which is used in example mentioned in the github link. This dataset I am using is of dimensions as follows after preprocessing (260000,28047) and also the classes(labels) range from 0:13. >>> import os >>> import tensorflow as tf >>> from tensorflow.python import keras >>> from tensorflow.python.keras

ValueError: Error when checking target: expected dense_2 to have shape (1,) but got array with shape (14,)

折月煮酒 提交于 2021-01-18 04:40:48
问题 I am trying to train a classification model in a distributed way. I am using TensorflowOnSpark library developed by Yahoo. The example I am using github link I am using dataset other than mnist which is used in example mentioned in the github link. This dataset I am using is of dimensions as follows after preprocessing (260000,28047) and also the classes(labels) range from 0:13. >>> import os >>> import tensorflow as tf >>> from tensorflow.python import keras >>> from tensorflow.python.keras

ValueError: Error when checking target: expected dense_2 to have shape (1,) but got array with shape (14,)

你说的曾经没有我的故事 提交于 2021-01-18 04:40:04
问题 I am trying to train a classification model in a distributed way. I am using TensorflowOnSpark library developed by Yahoo. The example I am using github link I am using dataset other than mnist which is used in example mentioned in the github link. This dataset I am using is of dimensions as follows after preprocessing (260000,28047) and also the classes(labels) range from 0:13. >>> import os >>> import tensorflow as tf >>> from tensorflow.python import keras >>> from tensorflow.python.keras

手把手教你简单的人脸识别

感情迁移 提交于 2021-01-14 06:54:58
最近人脸检测识别又火起来了,不知道大家知否两会期间都是人脸检测识别技术在后台监控,保证了我们两会期间的安全及监控工作,今天是我们CV进阶的第二节课,带领大家进入新的篇章,教你怎么用最近本的框架去实现人脸识别。 人脸检测及识别无处不在我们身边,只要你出门,就被摄像头一直监控着可以这么说。这也是为了我们社会安全! 在各个领域都已经用到了检测及识别技术最常见的是我们支付宝刷脸支付及门禁系统。 那今天我们“计算机视觉战队”就和大家说说识别。今天主要是针对刚刚入门的同学,如果你还很感兴趣,接下来和我们一起学习吧!本次学习后,你会对识别有一个深入了解,也会对该领域有浓厚的兴趣! 今天我们主要以 实践 为主!!! 在实践之前,我们首先要做的就是搭建环境,这个在CV系列已经有详细的教学了,本次我们基于Python的keras为大家带来简单教学。 数据准备 首先你选定文件的位置,该文件主要有train、test、Model和predict四个文件夹,之后会说每个文件夹的用途。 建立好四个文件夹之后,在train这个文件夹中存放你要存放的训练集,如下图: 今天举例子我只用两个类别的人脸数据, 注: 在train文件在建立两个你存入训练数据的文件夹并命名,在测试集也一样的操作,数据量根据你个人而定。 上图就是训练集内的部分数据,其他训练集文件及测试集都一样的操作,这个是建模的基础。 建模型 注:

Custom Attention Layer using in Keras

非 Y 不嫁゛ 提交于 2021-01-13 09:49:51
问题 I want to create a custom attention layer that for input at any time this layer returns the weighted mean of inputs at all time inputs. For Example, I want that input tensor with shape [32,100,2048] goes to layer and I get the tensor with the shape [32,100,2048] . I wrote the Layer as follow: import tensorflow as tf from keras.layers import Layer, Dense #or from tensorflow.keras.layers import Layer, Dense class Attention(Layer): def __init__(self, units_att): self.units_att = units_att self.W

Understanding WeightedKappaLoss using Keras

大城市里の小女人 提交于 2021-01-13 06:00:50
问题 I'm using Keras to try to predict a vector of scores (0-1) using a sequence of events. For example, X is a sequence of 3 vectors comprised of 6 features each, while y is a vector of 3 scores: X [ [1,2,3,4,5,6], <--- dummy data [1,2,3,4,5,6], [1,2,3,4,5,6] ] y [0.34 ,0.12 ,0.46] <--- dummy data I want to adress the problem as ordinal classification, so if the actual values are [0.5,0.5,0.5] the prediction [0.49,0.49,0.49] is better then [0.3,0.3,0.3] . My Original solution, was to use sigmoid

Understanding WeightedKappaLoss using Keras

橙三吉。 提交于 2021-01-13 06:00:26
问题 I'm using Keras to try to predict a vector of scores (0-1) using a sequence of events. For example, X is a sequence of 3 vectors comprised of 6 features each, while y is a vector of 3 scores: X [ [1,2,3,4,5,6], <--- dummy data [1,2,3,4,5,6], [1,2,3,4,5,6] ] y [0.34 ,0.12 ,0.46] <--- dummy data I want to adress the problem as ordinal classification, so if the actual values are [0.5,0.5,0.5] the prediction [0.49,0.49,0.49] is better then [0.3,0.3,0.3] . My Original solution, was to use sigmoid