python – pytorch LSTM model with unequal hidden layer

i have tuned a lstm model in keras as follows. but i dont know how write that code in pytorch. i put my pytorch code here but i dont think be right, because It does not give the right answer. how much I searched, I could not find a sample code in pytorch for more than one lstm layer with unequal hidden layers. my input shape is (None,(60,10)) with output shape (None,15) Please express a similar example for my keras model in pytorch. Thank

my_Keras_model:

model_input = keras.Input(shape=(60, 10))
x_1 = layers.LSTM(160,return_sequences=True)(model_input)
x_1 = layers.LSTM(190)(x_1)
x_1 = layers.Dense(200)(x_1)
x_1 = layers.Dense(15)(x_1)
model = keras.models.Model(model_input, x_1)

my_pytorch_model:

input_dim = 10
hidden_dim_1 = 160
hidden_dim_2 = 190
hidden_dim_3 = 200
num_layers = 1
output_dim = 15

class LSTM(nn.Module):
    def __init__(self, input_dim, hidden_dim_1, hidden_dim_2, hidden_dim_3 ,num_layers, output_dim):
        super(LSTM, self).__init__()
        self.hidden_dim_1 = hidden_dim_1
        self.hidden_dim_2 = hidden_dim_2
        self.hidden_dim_3 = hidden_dim_3
        self.num_layers = num_layers
        
        self.lstm_1 = nn.LSTM(input_dim, hidden_dim_1, num_layers, batch_first=True)
        self.lstm_2 = nn.LSTM(hidden_dim_1, hidden_dim_2, num_layers, batch_first=True)
        self.fc_1 = nn.Linear(hidden_dim_2, hidden_dim_3)
        self.fc_out = nn.Linear(hidden_dim_3, output_dim)

    def forward(self, x):
        input_X = x
        h_1 = torch.zeros(num_layers, 1 , self.hidden_dim_1).requires_grad_()
        c_1 = torch.zeros(num_layers, 1 , self.hidden_dim_1).requires_grad_()
        h_2 = torch.zeros(num_layers, 1 , self.hidden_dim_2).requires_grad_()
        c_2 = torch.zeros(num_layers, 1 , self.hidden_dim_2).requires_grad_()
        out_put = ()
        
        for i, input_t in enumerate(input_X.chunk(input_X.size(0))):
          out_lstm_1 , (h_1, c_1) = self.lstm_1(input_t, (h_1.detach(), c_1.detach()))
          out_lstm_2 , (h_2, c_2) = self.lstm_2(out_lstm_1, (h_2.detach(), c_2.detach()))
          out_Dense_1 = self.fc_1(out_lstm_2(:, -1, :))
          out_Dense_out = self.fc_out(out_Dense_1)
          out_put += out_Dense_out
        out_put = torch.stack(out_put, 0).squeeze(1)
        return out_put

c# – Hash Set Filtering, mapping onto an unequal list with set business rules

Improve hash Set List filtering

enter image description here

UI Data that gets saved as a HashSet.

These respond to the PriorityCode values of 1-9 in the database.
This code all works fine and is according with the business rules, but however. This seems to be a terribly inefficient way to do this. How can this be improved?

    private static IEnumerable<TabularScheduledItemViewModel> FilterByPriority(
        IEnumerable<int> hashSet,
        IEnumerable<TabularScheduledItemViewModel> jobList)
    {
        if (!hashSet.Any()) return jobList;


        var mappedHash = new HashSet<int>();

        if (hashSet.Contains(1))
        {
            mappedHash.Add(1);
            mappedHash.Add(2);
            mappedHash.Add(3);
        }

        foreach (int i in hashSet)
        {
            if (i is 1 or 2 || i == 3) continue;
            mappedHash.Add(i + 2);
        }

        return mappedHash.Count == 0
            ? jobList
            : jobList.Where(c => mappedHash.Any(o => o == c.PriorityCode));
    }

sql server – Ola Hallengren DataBaseBackup to URL results in un-equal file sizes causing IO Device Error

we have been using Ola’s Maintenance Solution and Database backup direct to URL since we migrated our system to Azure IAAS. We have multi terabyte DB’s and therefore split the backups over multiple files to keep them below 195GB each.
We had no issues until the last couple of weeks where the Full backup started to fail with an IO Device Error, telling me that the file size was greater than the 195GB limit so I increased the @NumberOfFiles parameter.
The first week this worked, the next week it failed again even though the DB had only grown a few GB in size.
I ended up having to add 10 to the number of files parameter and the backup completed successfully.

The issue is, most files written to are approx 90GB and 4 are approx 180GB.
Does anyone know the reason for the un-equal file sizes and a way to prevent this?

EXECUTE [dbo].[DatabaseBackup]
@Databases = ”,
@URL = ”,
@BackupType = ‘FULL’,
@Compress = ‘Y’,
@Verify = ‘Y’,
@CheckSum = ‘Y’,
@LogToTable = ‘Y’,
@MaxTransferSize = 4194304,
@Blocksize = 65536,
@NumberOfFiles = 36

Thanks in advance

Input a frequency distribution with unequal class widths and estimate the mean and median

The websites I have visited and the texts available to me determine the mean of an unequal frequency distribution using

mean = Sum(class marks x frequency) / Sum(frequency).

This is an example I extracted from the internet:

enter image description here

The author computed the mean wickets as 152.889, which I recoded in Mathematica as

midpts = {40, 80, 125, 200, 300, 400};
freq = {7, 5, 16, 12, 2, 3};   
mean = midpts . freq /Total(freq) // N
median = 100.5 + ((Total(freq)/2 - (7 + 5))/50) 16 

Is it a correct solution? How about the unequal class widths?

How do I convert two lists of unequal length into coordinates?

I have the following two lists;

a = {-1.8, -1.6, -1.4, -1.2, -1., -0.7, -0.6, -0.4, -0.2, 0., 0.2, 0.4, 
    0.6, 0.8, 1., 1.2, 1.4, 1.6, 1.8}
b = {.2, .4, .6, .8, 1., 1.2, 1.4, 1.6, 1.8}

I want to convert this to coordinate points where every ai value matches every bi. In essence, (-1.8, .2), …., (- 1.8,1.8) would be the first 9 points and points would be generated for all 19 values ​​of a.

Radix Sort for unequal strings that do not work

I've been trying to get a working radix strain for days, and I'm on my mind. At first I thought that LSD would work for strings of unequal lengths, then I read somewhere that MSD Radix was the only one that would work. Now I'm back at LSD. I know there are some issues with my indexes, but I just can not find them. I also have trouble understanding what to do with the strings for the buffer characters (ie, I put them somewhere and then attach them to the digit strings when sorted, etc.). Also, I always get a 0 instead of the first or last index of the sorted list (for the first iteration anyway).

If someone who really knows what he's talking about can give me some advice or tips on what I can do for this function to produce a sorted list of strings, I'd be very grateful.

Many Thanks

Code:

INPUT = list of strings without punctuation

def count_sort (lst, digit):
count = [0] * 27 # length of the alphabet
Temp = [0] * lst
# Key indexed sorting
for i in range (len (lst)):
Index = ord (lst[i][digit]) -97 # lines are left[0...len(lst)-1][digit]
        
        
        
        if index <0:
Index = 26
number[index] + = 1
for k in the range (1,26):
number[k] + = count[k-1]
    for j in range (len (lst)):
Index = ord (lst[j][digit]) - 97
if index < 0:
            index = 26
        temp[count[index]-1] = lst[j]
        count[index] -= 1
    return temp


def wordSort(words_list):
    max_chars = 0
    for word in words_list:  # get length of largest word in list
        if len(word) > MAX_CHARS:
max_chars = len (word)
adjust_words = []
    for word in words_list: # adjusts the length of the words
adjust = ['.' * (max_chars - len(word))]
        adjust_words.append (word + & # 39; join (adjust))
words_list = adjust_words
print (words_list)
for characters in the range (max_chars-1, -1, -1):
words_list = count_sort (words_list, char)
print (words_list)
Return words_list

conditional – Comparison of two arrays of unequal length

I have two arrays, we say

Array1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
Array2 = {13, 4, 6, 20, 21};

I want to compare these two arrays with the bike array1 through all elements in array2, The output should be the position in each array where it meets a condition where the condition is array2[[m]]= array1[[n]]-1 is true. That is, the output should be:

Output = {6,2}

Because in array2, 5-1 = 4 $, (array1[[6]]= 5 and array2[[2]]= 4). So far my code is

output = {position[array1, #][[1, 1]],
position[array2, #][[1, 1]]} & /@ (I have no idea)

Where the code on the left side of Map indicates the locations of a true state. On the right side of Map I'm not sure what to do.

For clarity, the code I want is similar

output = {position[array1, #][[1, 1]],
position[array2, #][[1, 1]]} & / @ Crossing[array1, array2]

Unless I want the item's position array2 = array1-1 instead of when array1 = array2,

If women are unequal and less paid than men, why did they start marrying women just two years ago?

"If women are unequal and paid less than men, why did they start marrying women only two years ago?"

The two are not connected. The "women's march" is actually a feminist march that has been deliberately mislabeled to co-opt all women in feminism for supporting feminist politics. We know that this is a feminist march, not a women's march, because there were women who were forbidden to visit. For example, women from professional life were not allowed to participate. Republican supporters were not. In fact, any woman who criticized feminism was not welcome. If it was a women's march, it would only be important that it was a woman. Period!

The second part is that the marches were from then on all political anti-Trump and anti-Republican movements. Equal pay can be treated as a problem. But now everyone should understand that we have written Pay Equality into the law. This has been the case since 1963. Here is the Equal Pay Act, which legally guarantees equal pay.
https: //www.eeoc.gov/laws/statutes/epa.c …

Feminists simply reflect misleading studies or simply use the EARNINGS Labor Force Department, which measures the median earnings of all women against all men, to point out that there is a pay gap at the individual level, if that is clear not the case. Those who get paid less against the Equal Pay Act can claim damages and win. This has already happened in several high-profile instances.
,

,

Privacy – mixing unequal inputs

Suppose you have 3 inputs (Alice, Bob, Satoshi): 0.3, 1.3, 1.6,
For example, we can mix these inputs like this: 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.1, 0.1,
Or so: 1.3, 1.3, 0.3, 0.3,
Traditionally it is mixed like this (CoinShuffle / ZeroLink / BlindCoin): 0.3, 0.3, 0.3, 1, 1.3,

There are many combinations, but there are better and worse mixtures. I intuitively thought that I want anonymize most bitcoins in the cheapest way,
First, take the sum of the anonymity rates, weighted by the number of bitcoins. With the second mix example (1.3, 1.3, 0.3, 0.3) it would be:

  • alice: 0.3btc – 2.1= 2 anonset -> 2 * 0.3= 0.6
  • Bob: 1.3btc – 2.1= 2 anonset -> 2 * 1.3= 2.6
  • Satoshi: 1.3btc – 2.1= 2 anonset -> 2 * 1.3= 2.6 AND 0.3btc – 2.1= 2 anonset -> 2 * 0.3= 0.6

And the sum is: 0.6 + 2.6 + 2.6 + 0.6= 6.4

Next we want the cheapest possible mix, we have to minimize the number of outputs, in the second example it is 4. Finally, divide the number of outputs by the weighted sum of anons: 6.4 / 4 =What ever (1.6).
We want that What ever Number to be as high as possible. So we can anonymize most bitcoins in the cheapest way.
With the traditional mix What ever would 5 weighted Anonset sum / 5 output number= 1.

This makes my ad hoc 2nd algorithm exactly 60% more efficient.
I also wrote a small software that compared 3 different algos with 100 random inputs (results below).
The first one works like this: Always take the smallest input and pair it with the rest. As a result, many issues have been generated (as you can see, so many issues have been created that they overflow 173% of the default maximum Bitcoin transaction size.)
The second algo has always taken the second largest input and paired it with the biggest.
During the third algo I used middle out, so I took the middle entrance and paired it with as many inputs as possible. This was by far the best What ever Value: 149.

Test code: https://github.com/nopara73/ConsoleApp14/blob/master/ConsoleApp14/Program.cs

Which algorithm can lead to the optimal mix?