Questions tagged [zero-padding]

The practice of padding a number (or string) with zeros in order to match an expected number of characters or bytes.

The practice of padding a number (or string) with zeros in order to match an expected number of characters or bytes.

For example, if the expected length of a string is 6, the number '123' could be zero padded as '000123' in order to meet this expected length.

111 questions
2
votes
1 answer

Zero Pad a tuple(range(1,31))

I have a tuple of a range of numbers to indicate dates. I would like to zeropad the numbers so that the tuple if possible. current results ( 1,2,3,4,5....10,11,12, etc) wanted results (01,02,03,... 10,11,12, etc)
user12170100
2
votes
2 answers

padding zeros at the beginning of a printf statement C

I need to add 0's to some values. For example if the number is 14, i want to print out 00014. but I can't just use %05d because the number of padding I want is stored in a variable. If the variable is equal to 6, I want to print 000014. If it is…
DarkLeader
  • 589
  • 7
  • 17
2
votes
2 answers

padding zeroes to a tensor on both dimensions

I have a tensor t 1 2 3 4 5 6 7 8 And I would like to make it 0 0 0 0 0 1 2 0 0 3 4 0 0 5 6 0 0 7 8 0 0 0 0 0 I tried stacking with new=torch.tensor([0. 0. 0. 0.]) tensor four times but that did not work. t =…
Dex
  • 137
  • 2
  • 10
2
votes
2 answers

Get each sequence's last item from packed sequence

I am trying to put a packed and padded sequence through a GRU, and retrieve the output of the last item of each sequence. Of course I don't mean the -1 item, but the actual last, not-padded item. We know the lengths of the sequences in advance, so…
Bram Vanroy
  • 27,032
  • 24
  • 137
  • 239
2
votes
0 answers

Does zero padding in Keras requires a memory?

Does zero padding in Keras require a memory? model.add(ZeroPadding2D((1, 1))) if it yes does, is it will be like this? INPUT: [224x224x3] Memory: 224*224*3=150K Weight: 0 ZEROPAD_1: [226x226x3] Memory: 226*226*3=153K …
flyingduck92
  • 1,449
  • 2
  • 23
  • 39
2
votes
1 answer

PHP Associative Array Unexpected Behavior -- WHY?

Following is an associative array I am using in a chunk of PHP code that creates an organized table of performance dates and information using data from a SQL database. The code appears to have no problems (to me), but is not behaving correctly…
kapnKronik
  • 21
  • 1
2
votes
1 answer

Stack vectors of different lengths in Tensorflow

How can I stack vectors of different length in tensorflow, e.g. from [1, 3, 5] [2, 3, 9, 1, 1] [6, 2] get zero-padded matrix [1, 3, 5, 0, 0] [2, 3, 9, 1, 1] [6, 2, 0, 0, 0] Vector count is known at definition time, but their lengths are not.…
DikobrAz
  • 3,557
  • 4
  • 35
  • 53
2
votes
2 answers

Pad all dot-delimited substrings to the same length for all strings in array

I have this array: $versions = [ '1', '1.0.2.4', '1.1.0', '1.12.547.8' ]; And I want: $versions = [ '001', '001.000.002.004', '001.001.000', '001.012.547.008' ]; But, if I have this: $versions = [ '1', …
LVA
  • 103
  • 6
1
vote
2 answers

Need to pad numbers inside a semicolon separated vector in r

I have the following dataframe, and I need to manipulate column a to get to column a_clean: df=data.frame(a=c("1234-12;23456-123","12345-1234",NA,"1234-013;1234-014"),a_clean=c("01234-0012;23456-0123","12345-1234",NA,"1234-0013;1234-0014")) I need…
Ashti
  • 193
  • 1
  • 10
1
vote
0 answers

Questions about masks of padding in GPT

The GPT series models use the decoder of Transformer, with unidirectional attention. In the source code of GPT in Hugging Face, there is the implementation of masked attention: self.register_buffer( "bias", …
1
vote
0 answers

how to pad a set of numpy feature files to same shape?

I have a set of feature files in numpy format in a folder and would like to vstack them so i can add input_shape in my neural network, input_shape=(21,2048) . The numpy files as as in picture; The size of the np files are different, example: (16,…
1
vote
3 answers

How to make `bc` output a desired number of base-2 binary digits

This outputs 101110 echo "obase=2; 46" | bc How can I make it output 8 digits, like this? : 00101110 I learned the above usage of bc here: Bash shell Decimal to Binary base 2 conversion See also my answer to that question here.
Gabriel Staples
  • 36,492
  • 15
  • 194
  • 265
1
vote
3 answers

left padding with python

I have following data and link combination of 100000…
Vicky
  • 11
  • 3
1
vote
4 answers

What is the regex to match everything after leading zeros

I want to know how to match a string after zeros at the beginning of a string. so example cases of what the string should match are ABC0123 -> ABC0123 0ABC0123 -> ABC0123 000ABC0123 -> ABC0123 I have tried [^0]+$ but that would return the below…
Darrell123
  • 53
  • 6
1
vote
3 answers

How do I best add 0's to beginning of range.value until it is 13 characters long in Excel?

I'm writing a function which needs to look up a code of a certain length in a different range, but not all codes are the correct length. In this range, that is fixed by having extra zeroes in front of it. So I am trying to write part of a macro that…