sequences

LSTM Sequence Prediction in Keras just outputs last step in the input

心已入冬 提交于 2019-12-06 07:24:07
I am currently working with Keras using Tensorflow as the backend. I have a LSTM Sequence Prediction model shown below that I am using to predict one step ahead in a data series (input 30 steps [each with 4 features], output predicted step 31). model = Sequential() model.add(LSTM( input_dim=4, output_dim=75, return_sequences=True)) model.add(Dropout(0.2)) model.add(LSTM( 150, return_sequences=False)) model.add(Dropout(0.2)) model.add(Dense( output_dim=4)) model.add(Activation("linear")) model.compile(loss="mse", optimizer="rmsprop") return model The issue I'm having is that after training the

How in OS/X to get 'seq' command-line functionality?

老子叫甜甜 提交于 2019-12-06 02:42:49
I'm still on Snow Leopard (I know...) so forgive if this is fixed in one of the later versions of OS/X, but I want to do standard "seq" aka: for i in `seq 1 100` ; do cat /whatever > $i.txt ; done I thought installing GNU tools would do it, but apparently not. On my mac both of these work (OS X 10.8.5) Andreas-Wederbrands-MacBook-Pro:~ raven$ for i in {1..10}; do echo $i; done 1 2 3 4 5 6 7 8 9 10 Andreas-Wederbrands-MacBook-Pro:~ raven$ for i in `seq 1 10`; do echo $i; done 1 2 3 4 5 6 7 8 9 10 In Snow Leopard, you can use the jot command, which can produce sequential data like seq (and more,

Producing numeric sequences in R using standard patterns

人走茶凉 提交于 2019-12-05 20:48:47
问题 I am working on a project where I need to enter a number of "T score" tables into R. These are tables used to convert raw test scores into standardized values. They generally follow a specific pattern, but not one that is simple. For instance, one pattern is: 34,36,39,42,44,47,50,52,55,58,60,63,66,68, 71,74,76,79,82,84,87,90,92,95,98,100,103,106 I'd prefer to use a simple function to fill these in, rather than typing them by hand. I know that the seq() function can create a simple seqeuence,

Sequence reduction in R

ⅰ亾dé卋堺 提交于 2019-12-05 15:12:05
Assume you have a vector like so: v <- c(1,1,1,2,2,2,2,1,1,3,3,3,3) How can it be best reduced to a data.frame like this? v.df <- data.frame(value=c(1,2,1,3),repetitions=c(3,4,2,4)) In a procedural language I might just iterate through a loop and build the data.frame as I go, but with a large dataset in R such an approach is inefficient. Any advice? or more simply data.frame(rle(v)[]) with(rle(v), data.frame(values, lengths)) should get you what you need. values lengths 1 3 2 4 1 2 3 4 来源: https://stackoverflow.com/questions/3010790/sequence-reduction-in-r

Linq statement for an infinite sequence of successive halves

陌路散爱 提交于 2019-12-05 04:53:49
Given a starting number, imagine an infinite sequence of its successive halves. 1, 0.5, 0.25, 0.125, ... (Ignore any numerical instabilities inherent in double .) Can this be done in a single expression without writing any custom extension methods or generator methods? I don't know of a single-expression way but I found this clever generator code here: http://csharpindepth.com/articles/Chapter11/StreamingAndIterators.aspx public static IEnumerable<TSource> Generate<TSource>(TSource start, Func<TSource,TSource> step) { TSource current = start; while (true) { yield return current; current = step

Why there is no List.skip and List.take?

吃可爱长大的小学妹 提交于 2019-12-05 01:28:51
Why there is no List.skip and List.take? There is of course Seq.take and Seq.skip, but they does not create lists as a result. One possible solution is: mylist |> Seq.skip N |> Seq.toList But this creates first enumerator then a new list from that enumerator. I think there could be more direct way to create a immutable list from immutable list. Since there is no copying of elements internally there are just references from the new list to the original one. Other possible solution (without throwing exceptions) is: let rec listSkip n xs = match (n, xs) with | 0, _ -> xs | _, [] -> [] | n, _::xs

How can I merge two sequences in clojure?

半腔热情 提交于 2019-12-04 22:16:45
What is an idiomatic way to merge (or retrieve the union of) two lists (or sequences) in Clojure? (merge l1 l2) doesn't seem to be the solution: a=> (merge '(1 2 3) '(2 3 4)) ((2 3 4) 1 2 3) I think andih's solution works great. Here is an alternate way because hey why not. It uses concat and distinct : user> (distinct (concat '(1 2 3) '(2 3 4))) => (1 2 3 4) One way to get the union of two lists is to use union Clojure> (into #{} (clojure.set/union '(1,2,3) '(3,4,5))) #{1 2 3 4 5} or if you want to get a list (into '() (into #{} (clojure.set/union '(1,2,3) '(3,4,5)))) (5 4 3 2 1) If what you

Convert List of Numbers to String Ranges

百般思念 提交于 2019-12-04 05:24:35
I'd like to know if there is a simple (or already created) way of doing the opposite of this: Generate List of Numbers from Hyphenated... . This link could be used to do: >> list(hyphen_range('1-9,12,15-20,23')) [1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 15, 16, 17, 18, 19, 20, 23]: I'm looking to do the opposite (note that 10 and 21 are included so it would be compatible with the range function, where range(1,10)=[1,2,3,4,5,6,7,8,9]): >> list_to_ranges([1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 15, 16, 17, 18, 19, 20, 23]) '1-10,12,15-21,23' Eventually, I would like to have the output also incorporate a step where

How do you get the next value in a sequence into a variable?

我是研究僧i 提交于 2019-12-04 05:06:49
So I'm writing a stored procedure and am having trouble getting the next value of a sequence into a variable. The sequence name is passed into the function and is stored as a varchar2 variable. How can you get the next value in that sequence into a local variable. Something like this? create or replace procedure next_val (p_sequence_name varchar2) as v_nextval integer; v_select varchar2(100); begin v_select := 'select '||p_sequence_name||'.nextval from dual'; execute immediate v_select into v_nextval; dbms_output.put_line('Nextval is: '||TO_CHAR(v_nextval)); end; 来源: https://stackoverflow.com

Pandas Find Sequence or Pattern in Column

与世无争的帅哥 提交于 2019-12-04 04:13:27
问题 Here's some example data for the problem I'm working on: index Quarter Sales_Growth 0 2001q1 0 1 2002q2 0 2 2002q3 1 3 2002q4 0 4 2003q1 0 5 2004q2 0 6 2004q3 1 7 2004q4 1 The Sales_Growth column tells me if there was indeed sales growth in the quarter or not. 0 = no growth, 1 = growth. First, I'm trying to return the first Quarter when there were two consecutive quarters of no sales growth. With the data above this answer would be 2001q1 . Then, I want to return the 2nd quarter of