keras

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

从BERT、XLNet到MPNet,细看NLP预训练模型发展变迁史

隐身守侯 提交于 2021-01-29 15:49:26
20世纪以来,自然语言处理(NLP)领域的发展涌现了许多创新和突破。NLP中许多之前机器不可能完成的任务,如阅读理解、人机对话、自动写新闻稿等,正逐渐成为现实,甚至超越了人类的表现。 如果总结过去20年里,无数先辈辛劳付出带来的璀璨成果,以下3个代表性工作列入NLP名人堂,应该实至名归: 1)2003年Bengio提出神经网络语言模型NNLM, 从此统一了NLP的特征形式——Embedding; 2)2013年Mikolov提出词向量Word2vec ,延续NNLM又引入了大规模预训练(Pretrain)的思路; 3)2017年Vaswani提出Transformer模型, 实现用一个模型处理多种NLP任务。 基于Transformer架构,2018年底开始出现一大批预训练语言模型,刷新众多NLP任务,形成新的里程碑事件。本文将跨越2018-2020,着眼于3个预训练代表性模型BERT、XLNet和MPNet,从以下4个章节介绍NLP预训练语言模型的发展变迁史: 1.BERT 原理及 MLM 简述 2.XLNet 原理及 PLM 简述 3.MPNet 原理及创新点简述 4.NLP预训练模型趋势跟踪 附录:快速上手BERT的4大工具包 1.BERT 原理及 MLM 简述 自谷歌2018年底开源BERT,NLP界的游戏规则某种程度上被“颠覆”了;一时间,这个芝麻街的可爱小黄人形象

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

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

Error when checking target: expected dense_1 to have shape (257, 257) but got array with shape (257, 1)

*爱你&永不变心* 提交于 2021-01-29 14:10:33
问题 print(X.shape,Y.shape) #(5877, 257, 1) (5877, 257, 1) model = Sequential() model.add(LSTM(257, input_shape=(257,1),stateful=False,return_sequences=True)) model.add(Dense(257, activation='sigmoid')) model.compile(loss=losses.mean_squared_error, optimizer='adam', metrics=['accuracy']) model.fit(x=X,y=Y,epochs=100,shuffle=False) Error when checking target: expected dense_1 to have shape (257, 257) but got array with shape (257, 1) I should give 5877 frames of size 257 to lstm layer. The output

Incremental learning in keras

假如想象 提交于 2021-01-29 13:30:34
问题 I am looking for a keras equivalent of scikit-learn's partial_fit : https://scikit-learn.org/0.15/modules/scaling_strategies.html#incremental-learning for incremental/online learning. I finally found the train_on_batch method but I can't find an example that shows how to properly implement it in a for loop for a dataset that looks like this : x = np.array([[0.5, 0.7, 0.8]]) # input data y = np.array([[0.4, 0.6, 0.33, 0.77, 0.88, 0.71]]) # output data Note : this is a multi-output regression

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 =

Error in Keras: “ AttributeError: 'Tensor' object has no attribute '_keras_history'”?

走远了吗. 提交于 2021-01-29 12:50:50
问题 I am using google colab, its a pretty simple network that uses an LSTM-BiLSTM and CRF. But I get this error " AttributeError: 'Tensor' object has no attribute '_keras_history'", when model.fit() is called. I understand that I shouldn't have any + operations or numpy.add() and replace them with ADD(), but this is not my case. I also tried wrapping it Lambda function but it didn't work out(I think I wasnt dong it right) Any help would be highly appreciated This is my code: input = Input(shape=

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

安稳与你 提交于 2021-01-29 12:21:01
问题 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 =

keras error:Error when checking target: expected dense_2 to have shape (2,) but got array with shape (1,)

北战南征 提交于 2021-01-29 11:53:46
问题 I have tried to write some example with keras,but some error happenError when checking target: expected dense_2 to have shape (2,) but got array with shape (1,) I have tried to change the input_shape but it doesn't work import keras from keras.models import Sequential from keras.layers import Dense from keras.optimizers import SGD from sklearn.preprocessing import LabelBinarizer from sklearn.model_selection import train_test_split import numpy print "hello" input=[[1],[2],[3],[4],[5],[6],[7],