category stringclasses 107
values | title stringlengths 15 179 | question_link stringlengths 59 147 | question_body stringlengths 53 33.8k | answer_html stringlengths 0 28.8k | __index_level_0__ int64 0 1.58k |
|---|---|---|---|---|---|
implement quantization | How to change this javascript code to show a modified image? | https://stackoverflow.com/questions/42734830/how-to-change-this-javascript-code-to-show-a-modified-image | <p>I am playing with image color quantization algorithms. I have found this link</p>
<p><a href="https://github.com/lokesh/color-thief" rel="nofollow noreferrer">Color Thief</a></p>
<p>where a javascript (a language that I have never studied) implementation of a modified median cut algorithm is presented. But the demo ... | <p>Here, I made this just for you.</p>
<p>I assume you want to <em>simplify</em> colors of an image to its palette provided by <code>color-thief</code>.</p>
<p>To achieve this I used <a href="https://github.com/lokesh/color-thief" rel="nofollow noreferrer">color-thief</a> and <a href="https://github.com/dtao/nearest-... | 1,534 |
implement quantization | Quantizing object detection model | https://stackoverflow.com/questions/63771573/quantizing-object-detection-model | <pre><code>[2] frozen_graph_file = # path to frozen graph (.pb file)
[3] input_arrays = ["normalized_input_image_tensor"]
[4] output_arrays = ['TFLite_Detection_PostProcess',
[5] 'TFLite_Detection_PostProcess:1',
[6] 'TFLite_Detection_PostProcess:2',
[7] 'TFLite_Detection_P... | <p>The implementation for TFLite_Detection_PostProcess is in <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/kernels/detection_postprocess.cc" rel="nofollow noreferrer">https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/kernels/detection_postprocess.cc</a></p>
<p>Regardle... | 1,535 |
implement quantization | Lossless jpeg compression in opencv | https://stackoverflow.com/questions/55814800/lossless-jpeg-compression-in-opencv | <p>Is it possible to achieve lossless compression in opencv without using an API such as libjpeg? I want to modify the DCT coefficients and get the same values when reading the image again. </p>
<p>I've tried to implement it like this : 8x8 RGB pixel blocks -> YCrCb -> DCT -> Quantization -> modify some coefficient va... | 1,536 | |
implement quantization | TensorRT/TFlite sample implementation | https://stackoverflow.com/questions/56911455/tensorrt-tflite-sample-implementation | <p>Having a trained '.h5' Keras model file, I'm trying to optimize inference time:</p>
<p>Explored 2 options:</p>
<ol>
<li>Accelerated inference via TensorRT</li>
<li>'int8' Quantization.</li>
</ol>
<p>At this point I can convert the model file to TensorFlow protobuf '.pb' format, but as a sidenote, it also contains... | <p>This is the user guide on how to use TensorRT in TF: <a href="https://docs.nvidia.com/deeplearning/frameworks/tf-trt-user-guide/index.html" rel="nofollow noreferrer">https://docs.nvidia.com/deeplearning/frameworks/tf-trt-user-guide/index.html</a></p>
<p>This talk explains how TensorRT works in TF: <a href="https://... | 1,537 |
implement quantization | How can I improve fixed-point data type utilization? | https://stackoverflow.com/questions/75937617/how-can-i-improve-fixed-point-data-type-utilization | <p>I'm trying to use the quantization for a convolutional neural network in order to reduce memory occupation going from the FP32 bit data type to Int16 one. The problem is that I'm obtaining poor results and since it's the first time that I use this kind of representation I have some doubts about the correct implement... | <p>You should check how much error is introduced into your values by rounding and clipping. Continue working with floating-point values, but introduce just rounding; then introduce just clipping; then introduce both. How much error is introduced in your results?</p>
<p>Also, regarding fixed-point format: even if it <em... | 1,538 |
implement quantization | How can I incorporate PReLU in a quantized model? | https://stackoverflow.com/questions/62891103/how-can-i-incorporate-prelu-in-a-quantized-model | <p>I'm trying to quantize a model which uses <code>PReLU</code>. Replacing <code>PReLU</code> with <code>ReLU</code> is not possible as it drastically affects the network performance to the point its useless.</p>
<p>As far as I know, <code>PReLU</code> is not supported in Pytorch when it comes to quantization. So I tri... | <p>I figured it out! I made a huge mistake in the very begining. I needed to calculate</p>
<pre><code>PReLU(x)=max(0,x)+a∗min(0,x)
</code></pre>
<p>or<br />
<a href="https://i.sstatic.net/OLWLW.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/OLWLW.png" alt="enter image description here" /></a><br />
and ... | 1,539 |
implement quantization | Run quantized tensorflow model on FPGA / pure python | https://stackoverflow.com/questions/53420994/run-quantized-tensorflow-model-on-fpga-pure-python | <p>I have a model trained in keras which is a simple model trained on MNIST dataset.</p>
<p>What I try to do is to rewrite this model and run on FPGA device.
In order to do this I want to fully understand how quantized model works.</p>
<p>First I converted this model with post training quantization to .tflite format ... | <p>There are two steps you'll need to do:</p>
<ol>
<li><p>Dequantize the input, weights and bias back into full precision (or integer equivalent)</p>
<p>(w-w_offset)*w_scale</p></li>
<li><p>After the Relu, quantize the activations back into integer</p>
<p>a/a_scale+a_offset</p>
<p>You can probably skip step 2 that ... | 1,540 |
implement quantization | MFCC Vector Quantization for Speaker Verification Hidden Markov Models | https://stackoverflow.com/questions/22338123/mfcc-vector-quantization-for-speaker-verification-hidden-markov-models | <p>I am currently doing a project on speaker verification using Hidden Markov Models. I chose MFCC for my feature extraction. I also intend to apply VQ to it. I have implemented HMM and tested it on Eisner's data spreadsheet found here: <a href="http://www.cs.jhu.edu/~jason/papers/" rel="nofollow">http://www.cs.jhu.edu... | <p>Well I am not sure about HMM approach but I would recommend using GMM. ALize is a great library for doing that. For Silence removal, use the LIUM library. The process is called speaker diarization, the program detects where the speaker is speaking and gives the time stamp.</p>
| 1,541 |
implement quantization | How to save quantized DCT coefficients as a JPEG image with Python? | https://stackoverflow.com/questions/56442098/how-to-save-quantized-dct-coefficients-as-a-jpeg-image-with-python | <p>I am creating a Python 3 application for steganography, specifically JPEG steganography. For this reason, I have to implement some basic JPEG compression to access the quantized DCT coefficients and embed bits into the LSBs. I have implemented all of this, but now I have a problem with saving the coefficients as a J... | 1,542 | |
implement quantization | GLCM Texture analysis in Sentinel-1 SNAP toolbox outputs texture with min and max pixel values not between 0 and 1 | https://stackoverflow.com/questions/51330883/glcm-texture-analysis-in-sentinel-1-snap-toolbox-outputs-texture-with-min-and-ma | <p>I have implemented GLCM Texture analysis on the Sentinel-1 SAR imagery. The imagery is high resolution. The parameters for the GLCM texture analysis are:</p>
<p><strong>Window size: 5x5</strong></p>
<p><strong>Quantizer: Probablistic Quantizer</strong> </p>
<p><strong>Quantization: 64 bit</strong> </p>
<p><... | <p>I guess you are getting 10 different images because for each image pixel you are performing the following operations:</p>
<ul>
<li>Define a neighbourhood of 5×5 centered at the considered pixel.</li>
<li>Compute the GLCM corresponding to <code>displacement=1</code> and <code>angle=0</code> of that neighbourho... | 1,543 |
implement quantization | Video processing Inter-frame Prediction | https://stackoverflow.com/questions/25278491/video-processing-inter-frame-prediction | <p>I need to perform 'Inter-frame Prediction' and 'Motion Compensation' of a set of 30 frames for video processing in Matlab. I am working with Mother-daughter frames. </p>
<p><img src="https://i.sstatic.net/Ybd3T.jpg" alt="enter image description here"></p>
<p>What I have done so far is to take the very first frame ... | <p>I'm going to assume that you are referring to the MPEG consortium of video compression algorithms (MPEG-1, MPEG-2, H.264, etc.). Let's answer each question one at a time:</p>
<h1>Question #1 - Frame Reconstruction</h1>
<p>For a single frame, the forward transformation basically consists of decomposing a frame int... | 1,544 |
implement quantization | Float ops found in quantized TensorFlow MobileNet model | https://stackoverflow.com/questions/48121702/float-ops-found-in-quantized-tensorflow-mobilenet-model | <p><a href="https://i.sstatic.net/jualG.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/jualG.png" alt="loat ops found in quantized TensorFlow MobileNet model "></a></p>
<p>As you can see in the screenshot of a quantized MobileNet model implemented in TensorFlow, there are still some float operations. T... | <p>Unfortunately there isn't a quantized version of depthwise conv in standard TensorFlow, so it falls back to the float implementation with conversions before and after. For a full eight-bit implementation of MobileNet, you'll need to look at TensorFlow Lite, which you can learn more about here:</p>
<p><a href="https... | 1,545 |
implement quantization | Optimize Albert HuggingFace model | https://stackoverflow.com/questions/70740565/optimize-albert-huggingface-model | <p>Goal: Amend this <a href="https://github.com/microsoft/onnxruntime-inference-examples/blob/main/quantization/notebooks/bert/Bert-GLUE_OnnxRuntime_quantization.ipynb" rel="nofollow noreferrer">Notebook</a> to work with <strong>albert-base-v2</strong> model</p>
<p>Kernel: <code>conda_pytorch_p36</code>.</p>
<p><strong... | <p>Optimise any PyTorch model, using <strong>torch_optimizer</strong>.</p>
<p>Installation:</p>
<pre class="lang-sh prettyprint-override"><code>pip install torch_optimizer
</code></pre>
<p>Implementation:</p>
<pre class="lang-py prettyprint-override"><code>import torch_optimizer as optim
# model = ...
optimizer = opti... | 1,546 |
implement quantization | Using custom activation function with TF-Lite | https://stackoverflow.com/questions/62194241/using-custom-activation-function-with-tf-lite | <p>I am new to TensorFlow Lite and ran into a problem using a custom activation function (f(x) = x^2).</p>
<p>Making the model quantization aware, compiling, training and evaluating works fine. However, trying to convert the model has turned into a problem. I tried following the "Quantization aware training comprehens... | 1,547 | |
implement quantization | Video Signature extraction in matlab | https://stackoverflow.com/questions/18787119/video-signature-extraction-in-matlab | <p>I am developing an application for Visual duplicate detection. For that First i have extract Frames from video. Then i have calculate KeyFrame which has Highest RMS error. Now i have to calculate Features of different subregion of frames which are configured at various scales,
shapes and locations. Then I have to a... | 1,548 | |
implement quantization | In scipy why doesn't idct(dct(a)) equal to a? | https://stackoverflow.com/questions/34890585/in-scipy-why-doesnt-idctdcta-equal-to-a | <p>I am trying to implement JPEG compression using python. When I tried to apply the DCT, quantization, IDCT process for a tiff image, I found something strange for scipy.fftpack.dct/idct.</p>
<p>Since there is only 1D dct/idct within scipy package, I was doing this for a 2D dct</p>
<pre><code>import numpy as np
from... | <p>You need to set scaling to <code>ortho</code> for both <code>dct2</code> and <code>idct2</code>:</p>
<pre><code>def dct2 (block):
return dct(dct(block.T, norm = 'ortho').T, norm = 'ortho')
</code></pre>
<p>also, you cannot expect the values to be exactly the same, but almost the same within some margin of error:... | 1,549 |
implement quantization | Approximating dot product between two real-valued vectors in Hamming space | https://stackoverflow.com/questions/68890746/approximating-dot-product-between-two-real-valued-vectors-in-hamming-space | <p>currently I am reading a paper about quantization in graph neural networks (<a href="https://arxiv.org/pdf/2012.15823.pdf" rel="nofollow noreferrer">https://arxiv.org/pdf/2012.15823.pdf</a>). On page two they talk about how you can approximate the dot product of two real-valued vectors a and b</p>
<p><a href="https:... | <p>You see that the derivation assumes <code>allclose(|x|, 1)</code></p>
<p><a href="https://i.sstatic.net/AKIlq.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/AKIlq.png" alt="enter image description here" /></a></p>
<p>With the rescaling <code>mean(|x|)</code> parameter you can have <code>allclose(|x|,... | 1,550 |
implement quantization | Other compression methods for Federated Learning | https://stackoverflow.com/questions/63456963/other-compression-methods-for-federated-learning | <p>I noticed that the Gradient Quantization compression method is already implemented in TFF framework. How about non-traditional compression methods where we select a sub-model by dropping some parts of the global model? I come across the "Federated Dropout" compression method in the paper "Expanding th... | <p>Currently, there is no implementation of this idea available in the TFF code base.</p>
<p>But here is an outline of how you could do it, I recommend to start from <a href="https://github.com/tensorflow/federated/tree/v0.16.1/tensorflow_federated/python/examples/simple_fedavg" rel="nofollow noreferrer"><code>examples... | 1,551 |
implement quantization | TFLite Conversion changing model weights | https://stackoverflow.com/questions/52726632/tflite-conversion-changing-model-weights | <p>I have a custom built tensorflow graph implementing MobileNetV2-SSDLite which I implemented myself. It is working fine on the PC.</p>
<p>However, when I convert the model to TFLite (all float, no quantization), the model weights are changed drastically. </p>
<p>To give an example, a filter which was initially -
... | <p>What command are you using to convert to tflite? For instance are you using toco, and if so what parameters are you using? While I haven't been looking at the filters, <a href="https://github.com/tensorflow/tensorflow/issues/22106#issuecomment-428409506" rel="nofollow noreferrer">here are my default instructions</a>... | 1,552 |
implement quantization | Php search keyword and output this line where keyword be | https://stackoverflow.com/questions/19393021/php-search-keyword-and-output-this-line-where-keyword-be | <p><strong>I would like to search for a keyword in a large text content and output this line.
My example text are as follow:</strong></p>
<p>HSPICE simulation methods for the nestlist of the proposed RTD-based nanoarchitecture in order to verify
a candidate of image functions by using the afore-mentioned representati... | <p>You want to use regex - <a href="http://www.php.net/manual/en/function.preg-match.php" rel="nofollow">http://www.php.net/manual/en/function.preg-match.php</a></p>
<pre><code>$search = 'General Terms:';
$pattern = '/'.$search.'(.)+/';
$content = 'HSPICE simulation methods for the nestlist of the proposed RTD-based... | 1,553 |
implement quantization | VHDL - Designing a simple first order IIR filter | https://stackoverflow.com/questions/29853221/vhdl-designing-a-simple-first-order-iir-filter | <p>I'm designing a simple first order IIR filter for my Spartan-6 but I'm struggling with bus widths and coefficient quantization.</p>
<p>The input data is 16-bits wide comes from integrated ADCs and the quantization noise is the main noise contribution to the front end noise.</p>
<p>The input signal is filtered at r... | <p>You deal with fractional coefficient by multiplying them by 2**N, just like you thought. This gives you a fixed point representation with N binary decimal places. You have to take care of keeping track of the fractional part width.</p>
<p>For example, if you multipy an input (16 bits integer, 0 bits fractional) wit... | 1,554 |
implement quantization | How to add a noise with uniform distribution to input data in Keras? | https://stackoverflow.com/questions/58484545/how-to-add-a-noise-with-uniform-distribution-to-input-data-in-keras | <p>I need to add quantization noise to my input data. I read often these kinds of noises are modeled as noise with uniform distribution. </p>
<p>I have an encoding/decoding network implemented with Keras (input data is time series raw data), there is a layer implemented in Keras with which you can add Gaussian noise (... | <p>You can create your own layer as such,</p>
<pre class="lang-py prettyprint-override"><code>import tensorflow as tf
class noiseLayer(tf.keras.layers.Layer):
def __init__(self,mean,std):
super(noiseLayer, self).__init__()
self.mean = mean
self.std = std
def call(self, input):
... | 1,555 |
implement quantization | Is there a way to monitor the different subtensors of a custom Keras backend loss function? | https://stackoverflow.com/questions/72437087/is-there-a-way-to-monitor-the-different-subtensors-of-a-custom-keras-backend-los | <p>I'm currently implementing a custom loss function by modelling it as a Keras backend tensor. The loss function has different parts (such as a classification loss, a quantization loss or a pairwise distance loss)</p>
<p>The code looks something like this:</p>
<pre><code>...
different_class_loss = K.log(1 + K.exp(-1*d... | <p>You can pass them as metrics, like this:</p>
<pre><code>def pl():
return pair_loss
pairwise_model.compile(optimizer=optimizer_adam, metrics=[pl])
</code></pre>
<p>And you can do similarly for your other loss components. The function might not be needed, you could also try passing <code>pair_loss</code> directly... | 1,556 |
implement quantization | Java: binary series representation | https://stackoverflow.com/questions/19139748/java-binary-series-representation | <p>I am doing some experiments on my own about quantization processes etc.</p>
<p>I try to implement a binarization process which makes a "binary string" which will get processed by xor afterwards and some other stuff.</p>
<p>Anyhow the binarization is the following, where d and u are some numbers that will get compa... | <p>The <a href="http://docs.oracle.com/javase/7/docs/api/java/util/BitSet.html" rel="nofollow"><code>BitSet</code></a> class is more appropriate for representing a sequence of bits. To set a bit you would use the <a href="http://docs.oracle.com/javase/7/docs/api/java/util/BitSet.html#set%28int%29" rel="nofollow"><code>... | 1,557 |
implement quantization | Generate the Dominant Colors for an RGB image with XMLHttpRequest | https://stackoverflow.com/questions/33312362/generate-the-dominant-colors-for-an-rgb-image-with-xmlhttprequest | <p><strong>A Note For Readers: This is a long question, but it needs a background to understand the question asked.</strong></p>
<p>The <a href="https://en.wikipedia.org/wiki/Color_quantization" rel="nofollow noreferrer">color quantization technique</a> is commonly used to get the <em>dominant colors</em> of an image.... | <p>The canvas element is being used as a convenient way to decode the image into an RGBA array. You can also use pure JavaScript libraries to do the image decoding.</p>
<p><a href="https://github.com/notmasteryet/jpgjs" rel="nofollow">jpgjs</a> is a JPEG decoder and <a href="https://github.com/arian/pngjs" rel="nofoll... | 1,558 |
implement quantization | Keras manual quantization | https://stackoverflow.com/questions/54525193/keras-manual-quantization | <p>I've recently inherited a keras based network from a colleague, and I want to quantize it down to 8 bit fixed point.</p>
<p>Unfortunately I'm not overly familiar with keras itself.</p>
<p>I've been looking around, and there doesn't seem to be any easy methods to do this, without converting to something like tf.lit... | <p>Perhaps you could use the <a href="https://github.com/transcranial/keras-js/blob/master/python/encoder.py" rel="nofollow noreferrer"><code>encoder.py</code></a> converter script with the <code>-q</code> quantization flag:</p>
<p><a href="https://transcranial.github.io/keras-js-docs/conversion/#quantization" rel="no... | 1,559 |
implement quantization | Method to quantize a range of values to keep precision when signficant outliers are present in the data | https://stackoverflow.com/questions/72894055/method-to-quantize-a-range-of-values-to-keep-precision-when-signficant-outliers | <p>Could you tell me please if there is a suitable quantizing method in the following case (preferrably implemented in python)?</p>
<p>There is an input range where majority of values are within +-2 std from mean, while some huge outliers are present.
E.g. [1, 2, 3, 4, 5, 1000]
Quantizing it to output range of e.g. 0-2... | <p>I can think of 2 answers to your question.</p>
<ol>
<li>You write "huge outlier". The term outlier suggest that this number does not really fit the data. If you really have evidence that this observation is not representative (say because the measurement device was broken temporarily), then I would omit th... | 1,560 |
implement quantization | Quantized dct not yielding runs of 0 | https://stackoverflow.com/questions/35514018/quantized-dct-not-yielding-runs-of-0 | <p>For quick reference here is a github <a href="https://github.com/DimitryRakhlei/MediaCompression" rel="nofollow">link</a>.</p>
<p>I am attempting to implement a simple JPEG compression.
I will provide some of the more notable methods.</p>
<p>The issue is that I am not seeing any notable runs of 0 so my RLE encodin... | 1,561 | |
implement quantization | TensorRT Post Training Quantization (INT8) generates incorrect results | https://stackoverflow.com/questions/76715132/tensorrt-post-training-quantization-int8-generates-incorrect-results | <p>This should really be a question for the NVIDIA team, but they are notoriously bad in providing support, so I am hoping instead that someone intimately familiar with the TensorRT C++ API can help me out.</p>
<p>I am unable to put a full minimum reproducible example in this code here, as there is a lot of boilerplate... | 1,562 | |
implement quantization | Tensorflow Quantization - Failed to parse the model: pybind11::init(): factory function returned nullptr | https://stackoverflow.com/questions/66731194/tensorflow-quantization-failed-to-parse-the-model-pybind11init-factory-f | <p>I'm working on a TensorFlow model to be deployed on an embedded system. For this purpose, I need to quantize the model to int8.
The model is composed of three distinct models:</p>
<ol>
<li>CNN as a feature extractor</li>
<li>TCN for temporal prediction</li>
<li>FC/Dense as last classfier.</li>
</ol>
<p>I implemented... | <p>As suggested by <a href="https://stackoverflow.com/users/11843861/jae-sung-chung">@JaesungChung</a>, the problem seems to be solved using tf-nightly (I tested on 2.5.0-dev20210325).</p>
<p>It's possible to obtain the same effect in 2.4.0 using a workaround and transforming the Conv1D into Conv2D with a width of 1 an... | 1,563 |
implement quantization | Closest point algorithm | How to improve it? | https://stackoverflow.com/questions/53264167/closest-point-algorithm-how-to-improve-it | <p>I wrote a k-means clustering algorithm and a color quantization algorithm. They work as expected in terms of results but I want to make them faster. In both implementations I need to solve a problem: there are two arrays of points in a 3D space, then for each point of the first array, you need to find the closest p... | <p>There are multiple data structures for efficient nearest neighbour queries. For 3d, a <a href="https://en.wikipedia.org/wiki/K-d_tree" rel="nofollow noreferrer">kdtree</a> works really well, and has a complexity of O(log n) for each query on average which would improve your current O(n). </p>
<p>So with this struct... | 1,564 |
implement quantization | Rounded division by power of 2 | https://stackoverflow.com/questions/6135157/rounded-division-by-power-of-2 | <p>I'm implementing a quantization algorithm from a textbook. I'm at a point where things pretty much work, except I get off-by-one errors when rounding. This is what the textbook has to say about that:</p>
<blockquote>
<p>Rounded division by <code>2^p</code> may be carried out by adding an offset and right-shifti... | <p>The shift will truncate. The shift is a binary operator operating. I'm using square brackets to denote the base here:</p>
<pre><code>196605[10] = 101111111111111111[2]
101111111111111111[2] >> 16[10] = 10[2] = 2[10]
</code></pre>
<p>To perform correct rounding you need to add half of your divisor before doin... | 1,565 |
implement quantization | Algorithm Complexity vs Running Time | https://stackoverflow.com/questions/37438314/algorithm-complexity-vs-running-time | <p>I have an algorithm used for signal quantization. For the algorithm I have an equation to calculate its complexity with different values of parameters. This algorithm is implemented in C. Sometimes according to the equation I have less complexity but the running time is higher. I'm not 100% sure about the equation.<... | <p>Time complexity is more a measure of how time varies with input size than an absolute measure.<br>
(This is an extreme simplification, but it will do for explaining the phenomenon you're seeing.)</p>
<p>If <code>n</code> is your problem size and your actual running time is <code>1000000000 * n</code>, it has linear... | 1,566 |
implement quantization | Matlab : Can SOM and kmeans be applied to binarize time series data? | https://stackoverflow.com/questions/40956532/matlab-can-som-and-kmeans-be-applied-to-binarize-time-series-data | <p>I found a similar question asked here <a href="https://stackoverflow.com/questions/19128859/determining-cluster-membership-in-som-self-organizing-map-for-time-series-data?rq=1">Determining cluster membership in SOM (Self Organizing Map) for time series data</a></p>
<p>and I want to learn how to apply self organizin... | <p>I don't know that I might be misunderstanding your question, but from what I understand it is really quite straight forward, both with <code>kmeans</code> and with Matlab's own <code>selforgmap</code>. The implementation you have posted for SOMSimple I cannot really comment on.</p>
<p>Let's take your initial exampl... | 1,567 |
implement quantization | Encoding ac and dc cofficients in jpeg compression after zigzag ordering | https://stackoverflow.com/questions/78916934/encoding-ac-and-dc-cofficients-in-jpeg-compression-after-zigzag-ordering | <p>I'm trying to implement JPEG compression in python and so far I have done the following steps</p>
<ul>
<li>Color Space conversion</li>
<li>Downscaling chrominance channels</li>
<li>8x8 block splitting ( adds padding if size is not perfect )</li>
<li>DCT</li>
<li>Quantization</li>
<li>ZigZag Ordering</li>
<li>runleng... | 1,568 | |
implement quantization | Hidden Markov Models with C++ | https://stackoverflow.com/questions/8562545/hidden-markov-models-with-c | <p>I've been looking into implementations of Hidden Markov Models in C++ lately. I was wondering If I could use any of the existing HMM libraries written in C++ out there to use
with Action Recognition (with OpenCV)?</p>
<p>I'm tying to AVOID "re-inventing the wheel"!</p>
<p>Is it possible to use <a href="http://torc... | <p>You can take a look at <a href="http://www.ece.ucsb.edu/Faculty/Rabiner/ece259/Reprints/tutorial%20on%20hmm%20and%20applications.pdf" rel="noreferrer">http://www.ece.ucsb.edu/Faculty/Rabiner/ece259/Reprints/tutorial%20on%20hmm%20and%20applications.pdf</a> for the theory behind HMMs. It's not hard to implement the al... | 1,569 |
implement quantization | Color quantization with N out of M predefined colors | https://stackoverflow.com/questions/21472245/color-quantization-with-n-out-of-m-predefined-colors | <p>I am having a slightly odd problem trying to quantize and dither an RGB image. Ideally, I should be able to implement a suitable algorithm in Java or use a Java library, but references to implementations in other languages may be helpful as well.</p>
<p>The following is given as input:</p>
<ul>
<li><code>image</co... | <p><strong>OVERVIEW</strong></p>
<p>This is a possible approach to the problem:</p>
<p>1) Each color from the input pixels is mapped to the closest color from the input color palette.</p>
<p>2) If the resulting palette is greater than the allowed maximum number of colors, the palette gets reduced to the maximum allo... | 1,570 |
implement quantization | Need a suggestion for a color palette data structure for iterative color quantization; in particular, any experiences with KD heaps? | https://stackoverflow.com/questions/57542028/need-a-suggestion-for-a-color-palette-data-structure-for-iterative-color-quantiz | <p>I am implementing color quantization that works in iterations. During each iteration, a new color palette is built up, and then that palette is searched through many times for the palette entry that best matches a given RGB triplet.</p>
<p>Also, I need to be able to access the palette in an array-like fashion so I ... | <p>It turned out that I was thinking too complicated. Also, there was a bug elsewhere that drastically impacted performance. A K-D tree packed in an array works fine, and with that other bug fixed, everything is OK.</p>
| 1,571 |
implement quantization | Question regarding color histogram based methods of generating color lookup-up tables | https://stackoverflow.com/questions/58399642/question-regarding-color-histogram-based-methods-of-generating-color-lookup-up-t | <p>I have a piece of code that needs to conform to a research paper's implementation of a color quantization algorithm for a 256 entry LUT whose 24-bit color entries are derived from a "population count" color histogram algorithm. The problem is that I don't know how the authors originally implemented their histogram a... | <p>try this <a href="https://stackoverflow.com/a/30265253/2521214">Effective gif/image color quantization?</a> its also histogram color quantization based, very similar to your approach but it create the histogram from 15 bit colors directly to spare space and do not use bins instead it sort colors by occurrence and us... | 1,572 |
implement quantization | Importing PIL images into FFMPY/FFMPEG to save as GIF/video | https://stackoverflow.com/questions/76305884/importing-pil-images-into-ffmpy-ffmpeg-to-save-as-gif-video | <p>I would like to know how I can transfer PIL images to FFMPY to save it as video, or gif, since the PIL library's quantization method has strong quality losses in certain cases. I first do some modifications with PIL, and then want to export and save the result.</p>
<p>I did not find any information on the topic onli... | <p>According to <code>ffmpy</code> documentation, it seems like the most relevant option is using <a href="https://ffmpy.readthedocs.io/en/latest/examples.html#using-pipe-protocol" rel="nofollow noreferrer">using-pipe-protocol</a>.</p>
<ul>
<li><p>Instead of using PIL for reading the images, we may read the PNG images ... | 1,573 |
implement quantization | What parts of the image tracing process can be handled by classes in the JDK? | https://stackoverflow.com/questions/19874745/what-parts-of-the-image-tracing-process-can-be-handled-by-classes-in-the-jdk | <p>I have a study assignment where I need to write a Java program to trace (vectorize) images. </p>
<p>I may only use the JDK 1.5 and up; so, I'll have to implement some algorithms where required. </p>
<p>The program has to pass the following steps:</p>
<ol>
<li>Color reduction (color quantization); [for a <em>set o... | <p>Classes written using the JDK can handle all aspects of the image tracing process (since Java is Turing complete and image tracers exist, they can be implemented in Java - QED). As for your specific areas of inquiry,</p>
<blockquote>
1) Yes! The JAI includes <a href="http://docs.oracle.com/cd/E17802_01/products/pro... | 1,574 |
implement quantization | C# PNG Image saving with selected filter | https://stackoverflow.com/questions/44764631/c-png-image-saving-with-selected-filter | <p>I couldn't help myself so once again I'm asking you for help. This time I will show the problem better than last time, I hope.</p>
<p>I'm writing a program to check if Quantization have any influence on image sizes. To do that I need to have implemented : </p>
<ol>
<li>Open PNG Image <em>(done)</em></li>
<li>"Quan... | <p>If the PNG libraries don't do what you want, just roll your own filters. It's not that difficult.</p>
<p>The filtering should take place inside the #region Quantization. As far as I unterstand it, the Valuator_v3() method converts the RGB channels separately, then you store the transformed pixel with Image111.SetPi... | 1,575 |
implement quantization | In the CVPR16 paper "Deepbit" by Kevin Lin, et al, is it a typo in the loss function section? | https://stackoverflow.com/questions/51280164/in-the-cvpr16-paper-deepbit-by-kevin-lin-et-al-is-it-a-typo-in-the-loss-func | <p>Recently I'm researching through possible ways of encoding images into compact binary descriptors that allows for fast image matching in a large corpus and came across <a href="http://www.iis.sinica.edu.tw/~kevinlin311.tw/cvpr16-deepbit.pdf" rel="nofollow noreferrer">this paper</a> written by Kevin Lin and his colle... | 1,576 | |
implement quantization | How to speed up color quantization via kmeans clustering | https://stackoverflow.com/questions/69062479/how-to-speed-up-color-quantization-via-kmeans-clustering | <p>I'm trying to speed up my implementation of "kmeans" clustering to minimize the number of colors in the image yet keep it pretty. It's extremely slow on the image 1000x1000 with k=32. But the function gives a perfect color/tone match (which is crucial) in comparison with the other tested approaches so I co... | 1,577 | |
implement quantization | How to implement ImageMagick command for halftone dither into ruby script? | https://stackoverflow.com/questions/43953119/how-to-implement-imagemagick-command-for-halftone-dither-into-ruby-script | <p>I'm trying to make a script for creating halftone dither. Script should take an rgb image and convert it to four png files for all CMYK channels, each being a bitmap with according threshold pattern, as in this image:</p>
<p><a href="https://i.sstatic.net/gBIvo.png" rel="nofollow noreferrer">halftone</a></p>
<p>So... | 1,578 | |
implement quantization | Wrong result after converting image from floating-point to unsigned in implementing JPEG | https://stackoverflow.com/questions/77307475/wrong-result-after-converting-image-from-floating-point-to-unsigned-in-implement | <p>I have a problem with my code in implementing the JPEG compression using OpenCV and C++. On the encoder and after the code does the DCT when I add a line of code, which converts the planes from 32-bit floating-point to 8-bit unsigned, I get some weird output as you can see below. After this conversion, besides the f... | 1,579 | |
DPO model | Pretrained Model Weights Not Updating During DPO Training | https://stackoverflow.com/questions/78664372/pretrained-model-weights-not-updating-during-dpo-training | <p>I'm trying to apply DPO to a pre-trained model. However, during the training process, the scores given by the pre-trained model and the fine-tuned model are identical, and the loss remains the same across all batches, leading me to believe the weights are not being updated. My training method is given below.</p>
<pr... | 0 | |
DPO model | How should the DPO algorithm be executed when the SFT model is unavailable? | https://stackoverflow.com/questions/78922265/how-should-the-dpo-algorithm-be-executed-when-the-sft-model-is-unavailable | <p><a href="https://i.sstatic.net/657AD55B.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/657AD55B.png" alt="enter image description here" /></a></p>
<p>The above image captures an excerpt from the original DPO paper.</p>
<p><strong>My current understanding of the DPO process is as follows:</strong></p>... | 1 | |
DPO model | Standford NLP library - How to identify similar words (Dash, DashPro, Dash Pro, Dpo, dpo) and get one word (DashPro) to match against training model? | https://stackoverflow.com/questions/79546447/standford-nlp-library-how-to-identify-similar-words-dash-dashpro-dash-pro | <p>Is there a way to identify similar words and convert it into one word before match against training model using Stanford NLP library?</p>
<p>For example, user inputs could be:</p>
<ol>
<li>DashPro</li>
<li>Dash Pro</li>
<li>dpo</li>
<li>Dash</li>
</ol>
<p>For all the above inputs, the return result should be "D... | 2 | |
DPO model | Optimizing an LLM Using DPO: nan Loss Values During Evaluation | https://stackoverflow.com/questions/78685861/optimizing-an-llm-using-dpo-nan-loss-values-during-evaluation | <p>I want to optimize an LLM based on DPO. When I tried to train and evaluate the model, but there are nan values in the evaluation results.</p>
<blockquote>
</blockquote>
<pre><code>import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from datasets import Dataset
from trl import DPOTrainer, DPOCon... | <p>I would first look for any Nan values in the data before training them if not try gradient clipping to prevent exploding gradients.</p>
| 3 |
DPO model | TypeError: empty_like(): argument 'input' (position 1) must be Tensor, not NoneType | https://stackoverflow.com/questions/79244854/typeerror-empty-like-argument-input-position-1-must-be-tensor-not-nonet | <p>I'm trying to fine-tune the "unsloth/Llama-3.2-11B-Vision-Instruct" model using the DPOTrainer from trl. My dataset is trl-lib/rlaif-v, and I verified its format aligns with the requirements for DPO training. However, when I run the code on Kaggle, I encounter the following error during training:</p>
<pre>... | 4 | |
DPO model | Hugging Face Model import error to Jupyter Notebook : | https://stackoverflow.com/questions/77658327/hugging-face-model-import-error-to-jupyter-notebook | <p>When I try to import a pre-trained fine tuned model from hugging face to jupyter notebook it's shows that the Kernel Restarting: The kernel for .ipynb appears to have died. It will restart automatically.</p>
<pre><code>from transformers import pipeline
pipe = pipeline("text-generation", model="lvkaok... | <p>As @Ro.oT has mentioned, it seems like you're running out of RAM when trying to load the model.</p>
<p>Check the below to reduce the RAM usage</p>
<ul>
<li>data pipeline : if it is too big before the model is loaded, discard some of the dataset</li>
<li>model pretrained checkpoint : I'm not sure, but downloading the... | 5 |
DPO model | Fine-tune llama2 on cuda:1 | https://stackoverflow.com/questions/76929997/fine-tune-llama2-on-cuda1 | <p>When I load the model I use device_map to use cuda:1 still it seems that the model and training are on different cores. How should I properly do this?</p>
<p>Code running at Tesla T4 below:</p>
<pre><code># load the base model in 4-bit quantization
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit... | 6 | |
DPO model | Linear layers for LORA | https://stackoverflow.com/questions/79476319/linear-layers-for-lora | <p>I have been trying to do DPO on the Llava models (llava-hf/llava-v1.6-mistral-7b-hf) and came across the training script Llava folks provided and realized that all the multimodal linear layers are ignored when selecting LORA targets. Can someone please explain why?</p>
<p><a href="https://github.com/LLaVA-VL/LLaVA-N... | 7 | |
DPO model | Predicting data from gamlss model in handler function using tryCatch in R | https://stackoverflow.com/questions/64638070/predicting-data-from-gamlss-model-in-handler-function-using-trycatch-in-r | <p>I am having a problem using the <code>tryCatch()</code> function in R in a function I created.</p>
<p>What I want to do is this:</p>
<ol>
<li>simulate data based on model results</li>
<li>analyze simulated data using my <code>gamlss</code> model</li>
<li>use the <code>predict</code> function to extract model predict... | <p>So after a bit of trial and error I managed to make it work. I believe the problem lies in the <code>mod_sim</code> object that is not saved to the global environment. <code>predict</code> (or <code>predict.gamlss</code> here) is probably not looking in the function environment for the <code>mod_sim</code> object al... | 8 |
DPO model | DDD / Presenter pattern VS Use case optimal query | https://stackoverflow.com/questions/20788646/ddd-presenter-pattern-vs-use-case-optimal-query | <p>In this great <a href="https://rads.stackoverflow.com/amzn/click/com/0321834577" rel="nofollow noreferrer" rel="nofollow noreferrer">book</a> about Domain-Driven Design, a chapter is dedicated to the user interface and its relationship to domain objects.</p>
<p>One point that confuses me is the comparison between U... | <p>Just a guess :)</p>
<p>The preseneter pattern could reuse your repository's aggregate finder methods as much as possible. For example, we have two views, in this case we need two adapters(an adapter per view), but we only need one repository find method:</p>
<pre><code>class CommentBriefViewAdapter {
private C... | 9 |
DPO model | How to show record int profile related to user using Laravel? | https://stackoverflow.com/questions/61463879/how-to-show-record-int-profile-related-to-user-using-laravel | <p>I want to show record into user's profile related to user. I am trying to do this unfortunately it's not showing record related to user. How to do this?</p>
<p><strong>Database</strong></p>
<pre><code> digitizing_orders table has user_id
</code></pre>
<p><strong>Digitizingorder</strong></p>
<pre><code> ... | <p>Since you have a <code>hasMany</code> relationship you can get digitizings like so:</p>
<pre><code> public function index()
{
$data=
[
'digitizings'=>Auth::user()->digitizing()->get()
];
return view('front_end.Customerprofi... | 10 |
DPO model | Trying to get property 'first_name' of non-object | https://stackoverflow.com/questions/61896917/trying-to-get-property-first-name-of-non-object | <p>I am trying to fetch digitizing order related to the user but unfortunately, I am facing an error.</p>
<p>Please see this error: <a href="https://flareapp.io/share/VmeWJ47Q" rel="nofollow noreferrer">https://flareapp.io/share/VmeWJ47Q</a></p>
<p><strong>Controller</strong></p>
<pre><code>public function index()
{
... | <p>Does every Digitizing-Entry has set a valid <code>user_id</code> in database? Try checking eager loaded data is set before accessing it.</p>
| 11 |
DPO model | Size mismatch for embed_out.weight: copying a param with shape torch.Size([0]) from checkpoint - Huggingface PyTorch | https://stackoverflow.com/questions/78712878/size-mismatch-for-embed-out-weight-copying-a-param-with-shape-torch-size0-f | <p>I want to finetune an LLM. I am able to successfully finetune LLM. But when reload the model after save, gets error. Below is the code</p>
<pre><code>import argparse
import numpy as np
import torch
from datasets import load_dataset
from transformers import AutoTokenizer, AutoModelForCausalLM
from trl import DPOTrai... | <p>Instead of</p>
<pre><code>model.save_pretrained(save_model_name)
</code></pre>
<p>try this</p>
<pre><code>dpo_trainer.save_model(save_model_name)
</code></pre>
| 12 |
DPO model | cyclic mss for icu beds---help writing the code - CPLEX | https://stackoverflow.com/questions/63934728/cyclic-mss-for-icu-beds-help-writing-the-code-cplex | <p>The OPL model is in the code box.<br />
My problem concerns the scheduling of the icu beds and I have a MIQP (mixed integer quadratic program) formulation.<br />
The goal is to level out the positive and negative deviation of the beds in intensive care,<br />
so that the use of one bed is balanced.<br />
For examp... | <p>If you run in the IDE you ll see some conflicts in the conflict tab.</p>
<p>And then if you comment the constraints mentioned in the conflicts:</p>
<pre><code>// constraint_6:
// forall (t in weekend)
// sum (c in speciality, r in OR) m[c][r][t]<=0;
// constraint_7:
// forall (t in days, r in ... | 13 |
DPO model | Triplet Network, loss function and equal distances | https://stackoverflow.com/questions/50621897/triplet-network-loss-function-and-equal-distances | <p>I'm currently implementing a triplet network to recognise if two images are describing the same 3d-model or not, but I have some problems with the results, the distances between anchor-positive is always equal to the distance between anchor-negative. </p>
<p>Here the code of my loss function :</p>
<pre><code> d... | 14 | |
DPO model | Deepspeed : AttributeError: 'DummyOptim' object has no attribute 'step' | https://stackoverflow.com/questions/78697835/deepspeed-attributeerror-dummyoptim-object-has-no-attribute-step | <p>I want to use deepspeed for training LLMs along with Huggingface Trainer. But when I use deepspeed along with trainer I get error "AttributeError: 'DummyOptim' object has no attribute 'step'". Below is my code</p>
<pre><code>import argparse
import numpy as np
import torch
from datasets import load_dataset... | <pre><code>from accelerate.utils import DistributedType
training_args.distributed_state.distributed_type = DistributedType.DEEPSPEED
</code></pre>
<p>adding this solves the issue</p>
| 15 |
DPO model | Adalm Pluto works on Ubuntu but NOT on Ubuntu Server 20.04 LTS | https://stackoverflow.com/questions/71949828/adalm-pluto-works-on-ubuntu-but-not-on-ubuntu-server-20-04-lts | <p>I'm running ubuntu server and have tried installing libiio packages from both source and apt-get repositories. I can detect the adalm pluto sdr device with iio_info -s (as root because I have not installed the udev rules) but it does not assume an ip address (e.g. 192.168.2.1) like it does on ubuntu 20.04 LTS.</p>
<... | 16 | |
DPO model | Error"AttributeError: 'product.pricelist' object has no attribute 'get_product_pricelist' | https://stackoverflow.com/questions/50290468/errorattributeerror-product-pricelist-object-has-no-attribute-get-product-p | <p>i'm using odoo 9 and i want to install module "product_print_zpl_barcode" with add a wizard on product variant which allows to generate and print a product barcode on a ZPL printer . When i press on the button "Print barcode" an error shows which said " AttributeError: 'product.pricelist' object has no attribute 'ge... | <p>You said it yourself, but it looks like you just missed it.</p>
<blockquote>
<p>Yes it exists</p>
<pre><code>def _get_product_pricelist(...):
...
</code></pre>
</blockquote>
<p>However, <code>_get_product_pricelist</code> is not the same as what you're calling, which is <code>get_product_pricelist</code>. <... | 17 |
DPO model | linuxkit getty getting stuck | https://stackoverflow.com/questions/46545259/linuxkit-getty-getting-stuck | <p>I am currently trying out linuxkit external disk.
However, getty is getting stuck whenever I placed binds definition, it would not go pass the login prompt. </p>
<pre><code>kernel:
image: linuxkit/kernel:4.9.52
cmdline: "console=tty0 console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:7804129bd06218b72c2981... | <p>The documentation is a little bit unclear on this: <code>binds</code> doesn't <strong>add</strong> the mount points, but <strong>replaces</strong> them. The documentation update is pending, but to solve your particular problem, just please put all the existing binds into the <code>.yml</code> (an example below shows... | 18 |
MCQA | Should i use threads when executing action method through AJAX? | https://stackoverflow.com/questions/7131500/should-i-use-threads-when-executing-action-method-through-ajax | <p>I am building a questionnarie. When a user clicks on an answer possibility for a multiple choice question (this is a radio button), i call an action method to save this answer. </p>
<p>The code:</p>
<pre><code><script language="javascript">
$(document).ready(function () {
$('.MCQRadio').click(function ... | <p>rather than saving your answer by post all the time, you can just create a JSOn object and save the answers within json. you can then at the end post all completed answers in one go.</p>
<p>take a look at this: <a href="http://msdn.microsoft.com/en-us/scriptjunkie/ff962533" rel="nofollow">http://msdn.microsoft.co... | 19 |
Fourier transform | Understanding where the constant $2/N$ comes from in Fourier transformation | https://dsp.stackexchange.com/questions/48049/understanding-where-the-constant-2-n-comes-from-in-fourier-transformation | <p>I'm implementing Fourier transformation in my analysis and I wanted dig a bit deeper on the reasons why the absolute value of Fourier transformation is usually multiplied by the constant <span class="math-container">$2/N$</span> to get the peak amplitude value of a sinewave with certain frequency.</p>
<p>In the book... | <p>The two comes from the fact that a real valued sinusoid is really the average of two complex one.</p>
<p>$$ \cos( \theta ) = \frac{ e^{i \theta} + e^{-i \theta} }{2} $$</p>
<p>There is the "2" in the denominator. In the DFT, the other half is located at bin $N-k$, if $k$ is the bin number.</p>
<p>That definitio... | 0 |
Fourier transform | How to determine the sine Fourier coefficients of discrete data? | https://dsp.stackexchange.com/questions/70037/how-to-determine-the-sine-fourier-coefficients-of-discrete-data | <p>The following relation gives me the measurements of interest <span class="math-container">$w$</span> at equally distanced locations <span class="math-container">$x_j$</span> in space:</p>
<p><span class="math-container">$$w_j=\sum_{m=1}^{11}A_m\sin\left(\frac{mπx_j}{L}\right)$$</span></p>
<p>where <span class="math-... | <p>With the correction, it can now be answered.</p>
<p>I will assume that you have also have 11 readings. Fewer and you are underdetermined, with more you are overdetermined.</p>
<p>Express your problem in matrix form.</p>
<p><span class="math-container">$$
\begin{bmatrix}
w_1 \\
w_2 \\
w_3 \\
: \\
w_{11} \\
\end{bm... | 1 |
Fourier transform | Fourier transform diagonalizes time-invariant convolution operators | https://dsp.stackexchange.com/questions/71261/fourier-transform-diagonalizes-time-invariant-convolution-operators | <p>I got the following paragraph from the book "A wavelet tour of signal processing" chapter one, page 2.</p>
<blockquote>
<p>The Fourier transform is everywhere in physics and mathematics because
<strong>it diagonalizes time-invariant convolution operators</strong>. It rules over linear time-invariant signal... | <p>For linear time invariant systems, complex exponentials are eigenfunctions - see <a href="https://ptolemy.berkeley.edu/eecs20/week9/lti.html" rel="nofollow noreferrer">here</a> and <a href="https://cnx.org/contents/d2CEAGW5@15.4:zRGnlxUF@2/Eigenfunctions-of-Continuous-Time-LTI-Systems" rel="nofollow noreferrer">here... | 2 |
Fourier transform | The Fourier transform of sinusoids' products with possible other components | https://dsp.stackexchange.com/questions/72820/the-fourier-transform-of-sinusoids-products-with-possible-other-components | <p>I know that in general it transforms the signal from the time to the frequency field but these specific cases seem pretty demanding. Do I calculate each part separately and then just leave them with convolution between them? Or do I have to calculate any integrals?</p>
<p><span class="math-container">\begin{align}
&... | <p><strong>HINT:</strong></p>
<p>It is easy to see that things can be simplified using the trigonometric product-to-sum identity in Equation <span class="math-container">$(1)$</span> below:
<span class="math-container">$$
\cos(\alpha)\cos(\beta) = \frac 12\big[\cos(\alpha+\beta) + \cos(\alpha-\beta)\big]\tag{1}
$$</spa... | 3 |
Fourier transform | Is it possible for a signal to be represented by *both* sinusoidal *and* rectangular/triangular Fourier transforms? | https://dsp.stackexchange.com/questions/158/is-it-possible-for-a-signal-to-be-represented-by-both-sinusoidal-and-rectang | <p>A signal might have both continuous and discrete parts (where the "discrete" parts are regions where a sinusoidal Fourier transform would be subject to unnecessary Gibbs Noise). So I would think that it could be useful, even if it would require an entirely different implementation strategy.</p>
<p>If it is possible... | <p>Yes, but it would be</p>
<ol>
<li><p>Calculation costly</p></li>
<li><p>coefficient would depend on number of harmonics $N$</p></li>
<li><p>depend on error norm</p></li>
<li><p>Most probably not worth the effort -you will probably be better with wavelets instead</p></li>
</ol>
<p>You can define $N$ and calculate l... | 4 |
Fourier transform | Basic question about trigonometric series and transforms thereof | https://dsp.stackexchange.com/questions/1303/basic-question-about-trigonometric-series-and-transforms-thereof | <p>I would like to know the relation between the parameters $\{\omega_k,A_k\;|\;k\in\mathbb{Z}\}$ of a series $\sum_kA_ksin(\omega_kx)$ and a related series, for example, $\sum_kA_k^2sin^2(\omega_kx)$.</p>
<p>I would also like to know why a multiplicity of peaks appears in the FT when the components of a series are ra... | <p>There is no general relationship between the Fourier transform of $f$ and that of $g(f)$ where $g$ is an arbitrary function. The Fourier transform does have the linearity property, so if $g$ is something simple like an affine transform, then the same linear relationship applies to their transforms $F$ and $G$.</p>
... | 5 |
Fourier transform | Signal Reconstruction after fourier transform | https://dsp.stackexchange.com/questions/3231/signal-reconstruction-after-fourier-transform | <p>I'm working from an example posted <a href="http://www.mathworks.com/help/techdoc/math/brentm1-1.html" rel="nofollow">here</a>. I understand the steps to acquire the fourier transform and can clearly see the spikes at normalized frequencies at 15 and 40 Hz from the 0-centered periodogram. Knowing this, I believe t... | <p>Suppose you want to perform <code>N</code> points FFT, then the evenly spaced frequency vector is given by</p>
<pre><code> f= (0:NumUniquePts-1)*Fs/N;
</code></pre>
<p>where <code>NumUniquePts = ceil((N+1)/2)</code> is the number of unique points in <code>f</code>, and <code>Fs</code> is the sampling rate.</p>
<... | 6 |
Fourier transform | What is the role of complex exponential? | https://dsp.stackexchange.com/questions/8482/what-is-the-role-of-complex-exponential | <p>What is the role of complex exponential $ e^{jθ} $ in Fourier Transform? Is it different in the continuous and in discrete time domain?</p>
| <p>Euler's relationship says that $e^{j\Theta}$ is equal to $cos(\Theta) + j*sin(\Theta)$. The Fourier Transform can then be seen as correlating the signal with sinusoids at various frequencies. The continuous Fourier Transform correlates with an infinite number of sinusoids, while the discrete transform uses $N$ sin... | 7 |
Fourier transform | Spatial Aliasing - Wrap Around F-K Spectra | https://dsp.stackexchange.com/questions/10036/spatial-aliasing-wrap-around-f-k-spectra | <p>I've been using F-K Filter, for a while, but I guess I never had good basic understanding about it Math. Someone asked me what is the cause of frequency wrap around in F-K Spectra plot ? I know it's because of aliasing. But if somebody please elaborate more on the cause of this wrap around? Simple Math explanation p... | <p>Aliasing and frequency wrap is a consequence of violation of <strong><em>Nyquist-Shannon sampling theorem</em></strong> which states that a continuous signal must be discretely sampled at least twice the frequency of the highest frequency in the signal.Hence we need to briefly go into the mathematics of the same.</p... | 8 |
Fourier transform | Can I apply Fourier Transform to a non-time-indexed signal? | https://dsp.stackexchange.com/questions/10783/can-i-apply-fourier-transform-to-a-non-time-indexed-signal | <p>Say I have a signal that is not x-indexed. That is, the x-axis of the signal is the distance traversed by car and the y-axis is the heading direction of the car at the corresponding distance.</p>
<p>Can I apply the Fourier Transform to this signal?
If so, what is the physical meaning of this transformation? I belie... | <p>Yes you can. The unit of the "frequency" axis after the transform will be $m^{-1}$, and is known as <a href="http://en.wikipedia.org/wiki/Spatial_frequency" rel="noreferrer">spatial frequency</a>.</p>
<p>For example, if there is a strong peak in the Fourier transform at $3.10^{-4} m^{-1}$, it means that your origin... | 9 |
Fourier transform | fourier transform to the power of two | https://dsp.stackexchange.com/questions/10933/fourier-transform-to-the-power-of-two | <p>Could someone explain to me why the computation speed for the fast Fourier transform increases by padding the series with zeros to the point that its length is close to a power of 2? This is common in the matlab environment, for example: </p>
<p><a href="http://www.mathworks.co.uk/help/matlab/ref/fft.html" rel="nof... | <p>Firstly the terminology: The thing that you are trying to compute is the Discrete Fourier Series (DFS). This the only flavor for Fourier Transforms that is discrete in both time and frequency and can thus be represented numerically inside a computer. The Fast Fourier Transform is a specific algorithm to computer the... | 10 |
Fourier transform | $\sin (t \omega)$ is not an Energy Signal, then how come its Fourier transform do exist? | https://dsp.stackexchange.com/questions/14990/sin-t-omega-is-not-an-energy-signal-then-how-come-its-fourier-transform-d | <p>The following integral (perhaps fourier tranform of $\sin (t \omega)$ ) is not convergent:</p>
<p>$\int_{-\infty }^{\infty } e^{-i t \omega } \sin (t \omega ) \, dt$</p>
<p>As, $\sin (t \omega)$ is NOT an Energy Signal (but a Power Signal), then how come we get successful in finding the fourier transform of $\sin ... | <p>You are right that such integrals are meaningless unless they are interpreted as distributions. And this is what we need to do, because - as you know - the Fourier transform of a sine function involves delta impulses. Let me try to make this a bit more intuitive:</p>
<p>The inverse Fourier transform of the delta fu... | 11 |
Fourier transform | Fourier Transform Form: two sin components & a phase shift & a magnitude for only one term | https://dsp.stackexchange.com/questions/16582/fourier-transform-form-two-sin-components-a-phase-shift-a-magnitude-for-onl | <p>This is an example from my text book of a continuous signal:
$$x_{in}(t)=\sin \left( 2\pi \cdot 1000 \cdot t\right) + 0.5\sin \left( 2\pi \cdot 2000 \cdot t + \dfrac{3\pi}{4} \right) $$
So to perform a fourier transform on this signal, how to do that, isn't it a bit funny, since it has two sine components. Shouldn't... | <p>Fourier Transform is a linear one, so you can make use of superposition principle:</p>
<p>$$ \mathscr{F} [\alpha x(t) + \beta y(t)] = \alpha \mathscr{F}[x(t)] + \beta \mathscr{F}[y(t)] $$</p>
<p>So for the <strong>first component</strong> $$x(t) = \sin \left( 2\pi \cdot 1000 \cdot t\right)$$</p>
<p>by <a href="ht... | 12 |
Fourier transform | What part of complex number of inverse discrete Fourier transform? | https://dsp.stackexchange.com/questions/18251/what-part-of-complex-number-of-inverse-discrete-fourier-transform | <p>Ok, so we have an image that is a Fourier inverse of the original picture. We want to get the original picture back. We use Matlab to get that job done. We import the image and then we invert it with the help of ifft(), this gives us a matrix with complex numbers. But to get the original picture we need to do some o... | <p>To apply <code>IFFT</code> you need back the signal do complex numbers, you need use magnitude and phase information to rebuild correctly.</p>
<p>The real part is = <code>magnitude * cos(phase)</code></p>
<p>The imaginary part is = <code>magnitude * sin(phase)</code></p>
<p>You can use square roots of −1 (<code>s... | 13 |
Fourier transform | Fourier Transform Problem - absolute value, time-saving tricks, etc | https://dsp.stackexchange.com/questions/18967/fourier-transform-problem-absolute-value-time-saving-tricks-etc | <p>I am given the following signal:</p>
<p>$$[e^{-at}cos(w_{o}t)]u(t),\ a>0$$</p>
<p>Then I am told to find the Fourier Transform, which tells me I need an answer of the form:
$$X(jw)=\int_{-\infty}^\infty \! x(t)e^{-jwt} \, \mathrm{d}t.$$</p>
<p>I know I can reset the bounds of my integral with the unit step fu... | <p>As you suggested, you could simply solve the integral using $\cos(\omega_0t)=(e^{j\omega_0t}+e^{-j\omega_0t})/2$. But as you've also noted, with this type of problems there is usually some smart way using known transform pairs. And what you suggested appears to me a very sane approach: convolve the known transform o... | 14 |
Fourier transform | why is the DFS of a delta function equal to 1 | https://dsp.stackexchange.com/questions/19509/why-is-the-dfs-of-a-delta-function-equal-to-1 | <p>I have a x[n] = $\delta$[n].
By formula is should be</p>
<p>$$</p>
<p>X[k]= \sum_{n=0}^{N-1} \delta[n]W_N^{kn}</p>
<p>X[k]= \sum_{n=0}^{N-1} e^{-j2*pi*kn/N}</p>
<p>$$</p>
<p>The formulae isn't showing for some reason. I took a screenshot of what I got here: <a href="https://imgur.com/6j0Ibgu" rel="nofollow nor... | <p>$X[k]= \sum_{n=0}^{N-1} \delta[n]W_N^{kn} \quad$, where $\>W_N^{kn}=e^{−j\,2\pi k\,n/N}$</p>
<p><strong>HINT:</strong></p>
<p>What is the value of $\delta[n]$ when $n \neq 0 \>$ ?</p>
| 15 |
Fourier transform | Can convolution of one signal with different signals give the same answer? | https://dsp.stackexchange.com/questions/23085/can-convolution-of-one-signal-with-different-signals-give-the-same-answer | <p>Let us consider $x_1(t)$, $x_2(t)$, $x_3(t)$, all the same within some some duration 0 to $T$ but all different outside this interval. Now let us multiply each of these signals with $w(t)$, a window function - nonzero from 0 to $T$ but 0 outside this interval. So the multiplication of this $w(t)$ with each of $x_i... | <p>Convolution is filtering. </p>
<p>Consider creating a filter with a rectangular response in the frequency domain. Then any signal with the same content within the filter's passband, no matter what the signal content outside the passband of the filter, should result in only the content within the passband after co... | 16 |
Fourier transform | What is Fourier transform in terms of area under the curve? | https://dsp.stackexchange.com/questions/23099/what-is-fourier-transform-in-terms-of-area-under-the-curve | <p>We know that integration gives area under the curve. And that FT is also an integration. How do we interpret FT in terms of the area under the curve especially because e^(jwt) is a complex term? In general, while dealing with complex terms in integration can we relate to some area?</p>
| <p>Since</p>
<p>$$X(\omega)=\int_{-\infty}^{\infty}x(t)e^{-j\omega t}dt$$</p>
<p>you get for the real part of $X(\omega)$ (assuming that $x(t)$ is real)</p>
<p>$$X_R(\omega)=\int_{-\infty}^{\infty}x(t)\cos(\omega t)dt\tag{1}$$</p>
<p>and for the imaginary part</p>
<p>$$X_I(\omega)=-\int_{-\infty}^{\infty}x(t)\sin(... | 17 |
Fourier transform | Fourier transform's sine and cosine count as N grows | https://dsp.stackexchange.com/questions/23323/fourier-transforms-sine-and-cosine-count-as-n-grows | <p>I remember reading that in (discrete) Fourier transform for signals with even numbered N for length, the sine and cosine count is equal. Is this correct?</p>
<p>A bit of analysis:</p>
<p>N=1, there is only DC offset, which is a cosine wave of unlimited length.</p>
<p>N=2, Now, in addition to the DC offset term th... | <p>As far as the rfft is concerned (real-valued time domain), your analysis is not exact even tough you are not far. First you have to remember that <code>rfft(x) -> X</code> transforms the time domain discreet signal <code>x</code> to a frequency spectrum X composed of N/2+1 real values and N/2+1 imaginary values (... | 18 |
Fourier transform | Numerical Fourier transform for exact frequency | https://dsp.stackexchange.com/questions/27022/numerical-fourier-transform-for-exact-frequency | <p>Mathematically, suppose I have a function $f(t)=\sum_k c_k e^{-i \omega_kt}$, where $\omega_k$ may not fall in $[0,2\pi]$. With an analytical Fourier transform, I can get a sum of delta functions centered at those frequencies. Now, I only have $N$ evenly-spaced points of $f(t_j)$ in the time domain $[0,T]$, albeit $... | 19 | |
Fourier transform | Is the following equation established? | https://dsp.stackexchange.com/questions/27315/is-the-following-equation-established | <p>Is the following equation established?</p>
<blockquote>
<p>$$\int_{-\infty}^{\infty}s(t)r^*(t)dt=\int_W S(f)R^*(f)df $$</p>
<p>$$s(t)\xrightarrow{\text{Fourier Transform}}S(f) $$</p>
<p>$$r(t)\xrightarrow{\text{Fourier Transform}}R(f) $$</p>
</blockquote>
| <p>It's a version of <a href="https://en.wikipedia.org/wiki/Parseval's_theorem" rel="nofollow">Parseval's Theorem</a>, which can be easily proved by noting that</p>
<p>$$\int_{-\infty}^{\infty}s(t)r^*(t)dt=\mathcal{F}\{s(t)r^*(t)\}\big|_{f=0}\tag{1}$$</p>
<p>where $\mathcal{F}$ denotes the Fourier transform. Note... | 20 |
Fourier transform | Frequency shift property of Fourier transform | https://dsp.stackexchange.com/questions/27383/frequency-shift-property-of-fourier-transform | <p>Which one of the following is actually a definition of frequency shift property
$$e^{j\omega_0 t}x(t)\leftrightarrow X(j\omega - \omega_0) \tag{1}$$
$$e^{j\omega_0 t}x(t)\leftrightarrow X(j(\omega - \omega_0)) \tag{2}$$<hr>
<strong>Is frequency shift applicaple in all the situations?</strong><hr></p>
<p>Case I<br>
... | <p>Your Eq. $(2)$ is the frequency shift property; Eq. $(1)$ is wrong. This is easy to show:</p>
<p>$$\begin{align}\mathcal{F}\left\{e^{j\omega_0t}x(t)\right\}=&\int_{-\infty}^{\infty}x(t)e^{j\omega_0t}e^{-j\omega t}dt\\&=\int_{-\infty}^{\infty}x(t)e^{-j(\omega-\omega_0)t}dt\\&=X(j(\omega-\omega_0))
\end{a... | 21 |
Fourier transform | What's a "Fourier filter"? | https://dsp.stackexchange.com/questions/27566/whats-a-fourier-filter | <p>E.g. the constant Q-transform is built by adding so called "Fourier filters".</p>
<p>What's a "Fourier filter"?</p>
| <p>People (usually from fields outside signal processing) sometimes use the term <a href="http://terpconnect.umd.edu/~toh/spectrum/FourierFilter.html" rel="nofollow noreferrer">Fourier filter</a> for a filtering operation in the FFT domain, which simply works by multiplying the FFT bins of a signal with a given filter ... | 22 |
Fourier transform | Fourier transform of ${\Pi}_{a}(t)\cos(2{\pi}f_{0}t)$ | https://dsp.stackexchange.com/questions/28317/fourier-transform-of-pi-at-cos2-pif-0t | <p>I want to find the following: $\mathfrak{F}[{\Pi}_{a}(t)\cos(2{\pi}f_{0}t)]$ <br>
<br>
I first did: $\mathfrak{F}[{\Pi}_{a}(t)] = 2a\text{ sinc}(2af)$ <br>
<br>then: $\mathfrak{F}[\cos(2{\pi}f_{0}t)] = \frac{1}{2}[\delta(f-f_{0})+\delta(f+f_{0})]$ <br></p>
<p>So: $$\begin{align}\mathfrak{F}[{\Pi}_{a}(t)\cos(2{\pi}f... | <p>Your last line is wrong. Note that you have</p>
<p>$$H(f)\star\delta(f-f_0)=H(f-f_0)\tag{1}$$</p>
<p>for any $H(f)$.</p>
<p>So your last line should be</p>
<p>$$\begin{align*}
&a\,\text{sinc}(2af)\star\delta(f-f_{0})+a\text{ sinc}(2af)\star\delta(f+f_{0})=\\&a\,\text{sinc}(2a(f-f_0))+a\,\text{sinc}(2a(f+... | 23 |
Fourier transform | Is it possible exctract sinusoids from non periodic signal? | https://dsp.stackexchange.com/questions/28599/is-it-possible-exctract-sinusoids-from-non-periodic-signal | <p>Digital signal <a href="http://hpiers.obspm.fr/eop-pc/index.php?index=C04&lang=en" rel="nofollow">UT1-UTC</a> is not periodic but is including many sinusoids (periodic elements in IERS nomenclature) that are not multiples of some fundamental. For example tidal sinusoids are not multiples of yearly seasonal sinus... | <p>Fourier's theorem say almost any (non-pathological) waveform, periodic or not, can be decomposed into sinusoids (or complex exponentials). Whether, or how well, those sinusoids correspond to any underlying pseudo-periodic phenomena or not is another issue.</p>
<p>Note that with a DFT, you may need to interpolate a... | 24 |
Fourier transform | What information does fourier transform carry? | https://dsp.stackexchange.com/questions/28856/what-information-does-fourier-transform-carry | <p>As one starts learning signal processing, then comes inevitably the topic of Fourier Transforms. Unfortunately I have difficulties not in computing but in interpreting the results of the Fourier Transforms, in particular the one being Continuous-Time Fourier Transform, CTFT, of the signal $x(t)$ which is: $$X(j\omeg... | <p>There are a variety of Fourier Transforms (and Series) such as Continuous Time FT, Discrete Time FT, Discrete FT all of which are generally attributed to the fundamental assertion made by J.B.Fourier about at the beginning of 19th century, which claims (without proof) that "if a continuous-time signal (function) x(t... | 25 |
Fourier transform | Which transformation in frequency domain equals a x-axis shift of a signal in time domain? | https://dsp.stackexchange.com/questions/29035/which-transformation-in-frequency-domain-equals-a-x-axis-shift-of-a-signal-in-ti | <p>I have discrete Fourier transformation results from measurements. Looking at the signal from the time domain perspective, I want to shift the signal on the $x$-axis to the left or right.</p>
<p>Which transformation in the frequency-domain results in a left/right shift in the time-domain?</p>
| <p>If $s(t)$ is your signal in time domain, you want to make the operation $s(t+\Delta t)$, which according to the <a href="https://en.wikipedia.org/wiki/Fourier_transform" rel="nofollow">Fourier's transform</a> properties, is equivalent to the operation :
$$
S(f)e^{j2\pi f\Delta t}
$$
$S(f)$ being $s(t)$ Fourier's tra... | 26 |
Fourier transform | Bandwidth range for Fast Fourier vs principal component analysis? | https://dsp.stackexchange.com/questions/29893/bandwidth-range-for-fast-fourier-vs-principal-component-analysis | <p>I've read somewhere that the Fast Fourier is only applicable to those processes exhibiting bandwidth. Where as principal component analysis can be applied to a process exhibiting any finite bandwidth. Why is this?</p>
<p>The band width is simply the difference in the upper and lower frequencies in a contentious se... | <p>From <a href="https://en.wikipedia.org/wiki/Karhunen%E2%80%93Lo%C3%A8ve_theorem" rel="nofollow">Karhunen–Loève theorem</a>, when talking about stochastic processes:</p>
<blockquote>
<p>In the theory of stochastic processes, the Karhunen–Loève theorem
(named after Kari Karhunen and Michel Loève), also known as t... | 27 |
Fourier transform | How is Linear Canonical Transform a generalization of Fractional Fourier Transform? | https://dsp.stackexchange.com/questions/30523/how-is-linear-canonical-transform-a-generalization-of-fractional-fourier-transfo | <p>I have studied that Fourier transform changes the domain of a signal from time to frequency, and in that way it is a 90 degree shift. When it comes to Fractional Fourier Transform a generalization of Fourier Transform, the resulting transform can lie anywhere between time and frequency domain depending on parameter ... | <p>The linear canonical transforms are all area preserving, orientation preserving, linear transforms on the time-frequency plane. The fractional Fourier transforms are a subset, namely the rotations. Both sets form (Lie-)groups under composition, and the rotations are a subgroup.</p>
| 28 |
Fourier transform | How to do addition of sound pressure RMS in a DFT | https://dsp.stackexchange.com/questions/34036/how-to-do-addition-of-sound-pressure-rms-in-a-dft | <p>Based on <a href="https://dsp.stackexchange.com/a/14935/23552">this</a> answer. Once you have your DFT in the unit sound pressure RMS, what is the correct method for getting the sound pressure RMS sum over multiple bins (if for example you're trying to get the total RMS over a frequency band)?</p>
| <p>The power spectrum of the DFT is the square of the magnitudes and is related to the power spectrum of the discrete time signal by Parsevel's theorem:</p>
<p>$$E_x=\sum_{k=0}^{N-1}\lvert x[k]\rvert ^2=\frac{1}{N}\sum_{k}^{N-1}\lvert X[k]\rvert^2.$$</p>
<p>The RMS is just the square root of the power. (I assume you'... | 29 |
Fourier transform | Time-dependent Fourier Transform (TDFT)? | https://dsp.stackexchange.com/questions/34967/time-dependent-fourier-transform-tdft | <p>In my DSP course we are learning right now about the Time-dependent Fourier Transform (TDFT), but I can't find any information about it online. </p>
<p>My professor said that it is similar to the Short-time Fourier Transform which I can find information about, except that whereas the STFT has a fixed signal and mov... | 30 | |
Fourier transform | What is (Fourier frame length/2 + 1)? | https://dsp.stackexchange.com/questions/35528/what-is-fourier-frame-length-2-1 | <p>If $N$ is discrete Fourier transform's frame length, and $N/2$ is half the frame length, how would you call $\frac N2 + 1$? </p>
<pre><code>frame_length = N ;
frame_length_half = N/2 ;
? = N/2 + 1;
</code></pre>
| <p>Using your notations: <code>number_frequency_bin</code>, i.e. the number of "non-redundant" frequency bins, the first (corresponding to the DC) and last (corresponding to Nyquist) ones being always real for a real signal. The first is a (normalized) sum of samples, the last a sum of samples with alternated signs (si... | 31 |
Fourier transform | Taking the FFT of a sinusoidal signal and going back | https://dsp.stackexchange.com/questions/36596/taking-the-fft-of-a-sinusoidal-signal-and-going-back | <p>I am a computer science student and want to do some stuff with audio data. I want to use the DFT to analyze and synthesize some sounds. Before going to the more complex stuff I experimented with basic tones and found some issues I do not understand - therefore I want to ask for help in this physics forum.</p>
<p>I ... | <p>Part of the problem is that you are using sine waves. The imaginary components of an FFT result contains all the information about pure sine waves (e.g. that are equivalent to a sin() function that starts with phase of zero at the start of the FFT aperture, and that are exactly integer periodic in aperture). If yo... | 32 |
Fourier transform | Application of the time-shifting property in case of Fourier-Transform of cosine | https://dsp.stackexchange.com/questions/36675/application-of-the-time-shifting-property-in-case-of-fourier-transform-of-cosine | <ol>
<li>Time-shifting property: $x[n-n_d] \xrightarrow{\mathscr{F}} e^{-j\omega n_d} X(e^{j\omega}) $</li>
<li>Fourier-Transform of cosine-signal: $\cos(\omega_0n) \xrightarrow{\mathscr{F}} \frac{1}{2}(\delta(\omega - \omega_0) + \delta(\omega+\omega_0)) $</li>
</ol>
<p>Combining 1. & 2. together, I am getting:
$... | <p>You have done a wrong calculation. First, you need to write the cosine as</p>
<p>$$
\cos(\omega_0n-\pi/2)=\cos\left(\omega_0(n-\tfrac{\pi}{2\omega_0})\right)
$$</p>
<p>i.e. the time-shift needs to be performed on the non-scaled version of the time variable $n$. Then, you apply the Fourier Transform:</p>
<p>$$
\ma... | 33 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.