neural-network

How to implement this NN architect using tensoflow?

假如想象 提交于 2020-03-04 23:03:35
问题 I am new in this domain perhaps thats why i am confusing things. I am unable to get the required results as it shows very low accuracy which means i am doing it wrong. import sklearn import pandas as pd from keras.models import Sequential from keras.layers import Dense from keras.layers import LSTM import matplotlib.pyplot as plt import sklearn.model_selection from tensorflow.keras import layers data= pd.read_csv("u.csv") #print(data.head()) plt.plot(data) plt.show() import tensorflow x=data

How to accumulate and appy gradients for Async n-step DQNetwork update in Tensorflow?

梦想与她 提交于 2020-02-27 22:22:21
问题 I am trying to implement Asynchronous Methods for Deep Reinforcement Learning and one of the steps requires to accumulate the gradient over different steps and then apply it. What is the best way to achieve this in tensorflow? I got so far as to accumulate the gradient and I don't think is the fastest way to achieve it (lots of transfers from tensorflow to python and back). Any suggestions are welcome. This is my code of a toy NN. It does not model or compute anything it just exercise the

How to accumulate and appy gradients for Async n-step DQNetwork update in Tensorflow?

ⅰ亾dé卋堺 提交于 2020-02-27 22:20:13
问题 I am trying to implement Asynchronous Methods for Deep Reinforcement Learning and one of the steps requires to accumulate the gradient over different steps and then apply it. What is the best way to achieve this in tensorflow? I got so far as to accumulate the gradient and I don't think is the fastest way to achieve it (lots of transfers from tensorflow to python and back). Any suggestions are welcome. This is my code of a toy NN. It does not model or compute anything it just exercise the

How to use model.reset_states() in Keras?

你说的曾经没有我的故事 提交于 2020-02-26 08:37:49
问题 I have sequential data and I declared a LSTM model which predicts y with x in Keras. So if I call model.predict(x1) and model.predict(x2) , Is it correct to call model.reset_states between the two predict() explicitly? Does model.reset_states clear history of inputs, not weights, right? # data1 x1 = [2,4,2,1,4] y1 = [1,2,3,2,1] # dat2 x2 = [5,3,2,4,5] y2 = [5,3,2,3,2] And in my actual code, I use model.evaluate() . In evaluate() , is reset_states called implicitly for each data sample? model

Improve Accuracy for a Siamese Network

£可爱£侵袭症+ 提交于 2020-02-25 02:10:11
问题 I wrote this little model using Keras Functional API to find similarity of a dialogue between two individuals. I am using Gensim's Doc2Vec embeddings for transforming text-data into vectors (vocab size: 4117). My data is equally divided up into 56 positive cases and 64 negative cases. (yes I know the dataset is small - but that's all I have for the time being). def euclidean_distance(vects): x, y = vects sum_square = K.sum(K.square(x - y), axis=1, keepdims=True) return K.sqrt(K.maximum(sum

Encog - Training a neural network with Cross-validation methods and validating the training

耗尽温柔 提交于 2020-02-24 00:49:56
问题 I would like to stop training a network once I see the error calculated from the validation set starts to increase. I'm using a BasicNetwork with RPROP as the training algorithm, and I have the following training iteration: void trainCrossValidation(BasicNetwork network, MLDataSet training, MLDataSet validation) { FoldedDataSet folded = new FoldedDataSet(training); Train train = new ResilientPropagation(network, folded); CrossValidationKFold trainFolded = new CrossValidationKFold(train,

Encog: How do I compute without ideal data?

依然范特西╮ 提交于 2020-02-23 07:41:06
问题 Here is an example of my code just to explain my question. (My code is not the XOR example and it has much more data): public static double XOR_INPUT[][] = { { 0.0, 0.0 }, { 1.0, 0.0 }, { 0.0, 1.0 }, { 1.0, 1.0 } }; public static double XOR_IDEAL[][] = { { 0.0 }, { 1.0 }, { 1.0 }, { 0.0 } }; ... MLDataSet trainingSet = new BasicMLDataSet(XOR_INPUT, XOR_IDEAL); ... for(MLDataPair pair: trainingSet ) { final MLData output = network.compute(pair.getInput()); System.out.println(pair.getInput()

How can a neural network architecture be visualized with Keras?

淺唱寂寞╮ 提交于 2020-02-19 14:57:10
问题 I tried the following: #!/usr/bin/env python import keras from keras.models import model_from_yaml model_file_path = 'model-301.yaml' weights_file_path = 'model-301.hdf5' # Load network with open(model_file_path) as f: yaml_string = f.read() model = model_from_yaml(yaml_string) model.load_weights(weights_file_path) model.compile(optimizer='adagrad', loss='binary_crossentropy') # Visualize from keras.utils.visualize_util import plot However, this gives an error: Traceback (most recent call

How can a neural network architecture be visualized with Keras?

半腔热情 提交于 2020-02-19 14:56:53
问题 I tried the following: #!/usr/bin/env python import keras from keras.models import model_from_yaml model_file_path = 'model-301.yaml' weights_file_path = 'model-301.hdf5' # Load network with open(model_file_path) as f: yaml_string = f.read() model = model_from_yaml(yaml_string) model.load_weights(weights_file_path) model.compile(optimizer='adagrad', loss='binary_crossentropy') # Visualize from keras.utils.visualize_util import plot However, this gives an error: Traceback (most recent call

How to fix RuntimeError “Expected object of scalar type Float but got scalar type Double for argument”?

折月煮酒 提交于 2020-02-19 09:32:07
问题 I'm trying to train a classifier via PyTorch. However, I am experiencing problems with training when I feed the model with training data. I get this error on y_pred = model(X_trainTensor) : RuntimeError: Expected object of scalar type Float but got scalar type Double for argument #4 'mat1' Here are key parts of my code: # Hyper-parameters D_in = 47 # there are 47 parameters I investigate H = 33 D_out = 2 # output should be either 1 or 0 # Format and load the data y = np.array( df['target'] )