neural-network

is it possible to retrain a previously saved keras model?

一个人想着一个人 提交于 2020-06-16 09:18:47
问题 i'm working in a time series prediction using keras and tensorflow. I need to retrain the model with future data. My question is, is this possible in keras and how we can do that? 回答1: yes. Save your model as .h5 When you want to train your model, load it again and do a model.fit as normal. Make sure you do not compile your model after loading it as this will reset your weights. See this link for more info 回答2: I am updating the answer for any new user as it was long time back. if you are

How do I get probability/confidence as output for a CNN using keras in python?

久未见 提交于 2020-06-16 07:41:10
问题 So, I'm new to deep learning and I've started with cats and dogs dataset for a CNN Model using Keras. In my code, I'm unable to get probabilities as output for both classifier.predict or classifier.predict_proba . I'm just getting the output as [[0,1]] or [[1,0]] . I've tried with several images. But I'm looking for something like, [[0.4,0.6]] , [[0.89,0.11]] I've tried changing loss function from binary_crossentropy to categorical_crossentropy . I've tried changing the activation function of

Forward vs reverse mode differentiation - Pytorch

一曲冷凌霜 提交于 2020-06-16 04:09:31
问题 In the first example of Learning PyTorch with Examples, the author demonstrates how to create a neural network with numpy. Their code is pasted below for convenience: # from: https://pytorch.org/tutorials/beginner/pytorch_with_examples.html # -*- coding: utf-8 -*- import numpy as np # N is batch size; D_in is input dimension; # H is hidden dimension; D_out is output dimension. N, D_in, H, D_out = 64, 1000, 100, 10 # Create random input and output data x = np.random.randn(N, D_in) y = np

How to input a classification time series data into LSTM

前提是你 提交于 2020-06-13 11:32:28
问题 I want to feed my data into a LSTM network, but can't find any similar question or tutorial. My dataset is something like: person 1: t1 f1 f2 f3 t2 f1 f2 f3 ... tn f1 f2 f3 . . . person K: t1 f1 f2 f3 t2 f1 f2 f3 ... tn f1 f2 f3 So i have k person and for each person i have a matrix like input. The first column of each row is incremental time stamp (like a time-line, so t1 < t2 ) and other columns are features of person in that time. In mathematical aspect: i have a (number of example,number

How to input a classification time series data into LSTM

拈花ヽ惹草 提交于 2020-06-13 11:32:12
问题 I want to feed my data into a LSTM network, but can't find any similar question or tutorial. My dataset is something like: person 1: t1 f1 f2 f3 t2 f1 f2 f3 ... tn f1 f2 f3 . . . person K: t1 f1 f2 f3 t2 f1 f2 f3 ... tn f1 f2 f3 So i have k person and for each person i have a matrix like input. The first column of each row is incremental time stamp (like a time-line, so t1 < t2 ) and other columns are features of person in that time. In mathematical aspect: i have a (number of example,number

How to Get Reproducible Results (Keras, Tensorflow):

孤人 提交于 2020-06-13 05:34:09
问题 To make the results reproducible I've red more than 20 articles and added to my script maximum of the functions ... but failed. In the official source I red there are 2 kinds of seeds - global and operational. May be, the key to solving my problem is setting the operational seed, but I don't understand where to apply it. Would you, please, help me to achieve reproducible results with tensorflow (version > 2.0)? Thank you very much. from keras.models import Sequential from keras.layers import

How to Get Reproducible Results (Keras, Tensorflow):

坚强是说给别人听的谎言 提交于 2020-06-13 05:33:12
问题 To make the results reproducible I've red more than 20 articles and added to my script maximum of the functions ... but failed. In the official source I red there are 2 kinds of seeds - global and operational. May be, the key to solving my problem is setting the operational seed, but I don't understand where to apply it. Would you, please, help me to achieve reproducible results with tensorflow (version > 2.0)? Thank you very much. from keras.models import Sequential from keras.layers import

BERT sentence embedding by summing last 4 layers

末鹿安然 提交于 2020-06-11 07:55:27
问题 I used Chris Mccormick tutorial on BERT using pytorch-pretained-bert to get a sentence embedding as follows: tokenized_text = tokenizer.tokenize(marked_text) indexed_tokens = tokenizer.convert_tokens_to_ids(tokenized_text) segments_ids = [1] * len(tokenized_text) tokens_tensor = torch.tensor([indexed_tokens]) segments_tensors = torch.tensor([segments_ids]) model = BertModel.from_pretrained('bert-base-uncased') model.eval() with torch.no_grad(): encoded_layers, _ = model(tokens_tensor,

What is the number of filter in CNN?

[亡魂溺海] 提交于 2020-06-09 07:24:24
问题 I am currently seeing the API of theano, theano.tensor.nnet.conv2d(input, filters, input_shape=None, filter_shape=None, border_mode='valid', subsample=(1, 1), filter_flip=True, image_shape=None, **kwargs) where the filter_shape is a tuple of (num_filter, num_channel, height, width) , I am confusing about this because isn't that the number of filter decided by the stride while sliding the filter window on the image? How can I specify on filter number just like this? It would be reasonable to

how can I split a large image into small pieces in python

[亡魂溺海] 提交于 2020-06-09 07:23:33
问题 I need to create 30 * 30 px small images from splitting a large image. I need these parts separately saved in separate files after being split up like so: 回答1: Here you go: import cv2 img = cv2.imread('image.png') for r in range(0,img.shape[0],30): for c in range(0,img.shape[1],30): cv2.imwrite(f"img{r}_{c}.png",img[r:r+30, c:c+30,:]) 来源: https://stackoverflow.com/questions/53755910/how-can-i-split-a-large-image-into-small-pieces-in-python