so i want to make a lstm network to run on my data but i get this message: ValueError: Error when checking input: expected lstm_1_input to have shape (None, 1) but got array with shape (1, 557) this is my code: Answer You need to change the input_shape value for LSTM layer. Also, x_train must have the following shape. So,
Tag: arrays
Working with 2 arrays to populate a third one in numpy
I am trying to work with two arrays in a certain way in python. Lets say now I have a target array C = [2, 7, 15, 25, 40]. I want to find a output value (say Y) for each element in C (say x) with conditions: If x < A[0] then Y = B[0] If A[i] < x <
Finding the minimum of the N numpy matrices?
I want to find the minimum of N numpy matrices elementwise (but with a twist, read till the end). To show, I create 3 numpy matrices as follows: I except my output d to be: I also need to retain the information from where does the each element in the d matrix is coming from. So if I label a,
How do i loop over a geometric sequence. i need to loop some function over 1, 2, 4, 8, 16
My code is This is what the program looks like Answer With generators: Output:
I need to append only those who has non null values in pyspark dataframe
I am having the pyspark dataframe (df) having below sample table (table1): id, col1, col2, col3 1, abc, null, def 2, null, def, abc 3, def, abc, null I am trying to get new column (final) by appending the all the columns by ignoring null values. I have tried pyspark code and used f.array(col1, col2, col3). Values are getting appended
Find the first and last element of a NumPy array larger than a threshold
I need to find the first and the last element of a numpy.ndarray which are above a specified threshold. I found the following solution, which works, but it looks a bit convoluted. Is there a simpler/more Pythonic way? Answer You could just access the first/last elements
Is there a way to create array with custom values using numpy array
Hello i want to ask is there a way to create an array with custom values without using loop and assign the values for example i want to create array with [2,1] shape and i want to fill the first column with value of (-1) and the second with value of (2) i have read the numpy docs “https://docs.scipy.org/doc/numpy-1.13.0/reference/routines.array-creation.html” but
How to Divide an array in to segments and then do sub segments of the segments using python numpy?
I want to do divide an 8*8 array in to 4 segments(each segment of 4*4 array) as shown below in step2. Then again divide each segment in to other small 4 subsegemnts(each subsegment of 2*2 array) and then find the mean of each subsegment and then find the stabbndard deviation of each segment using the 4 means of the 4
How do you scan characters in multi-character multi-string arrays in Python?
I’m working on my first Python project for a device that reads a string from OCR and outputs braille. The braille device can only output 6 letters at a time. I’m stuck trying to scan each character in the 6 character long multi-string array. For simplicity’s sake, for now I only want to print “this is (insert character)” for every
Finding Subarrays of Vowels from a given String
You are given a string S, and you have to find all the amazing substrings of S. Amazing Substring is one that starts with a vowel (a, e, i, o, u, A, E, I, O, U). Input The only argument given is string S. Output Return a single integer X mod 10003, here X is number of Amazing Substrings in