# Visualizing the Loss Landscape of Winning Lottery Tickets

Robert Bain

###### Abstract

The underlying loss landscapes of deep neural networks have a great impact on
their training, but they have mainly been studied theoretically due to
computational constraints. This work vastly reduces the time required to
compute such loss landscapes, and uses them to study winning lottery tickets
found via iterative magnitude pruning. We also share results that contradict
previously claimed correlations between certain loss landscape projection
methods and model trainability and generalization error.

Machine Learning, ICML

##  1 Introduction

Deep neural networks (DNNs) are frequently trained using one of the many
variants of stochastic gradient descent (SGD). These methods update a
network’s parameters using the gradients of the loss w.r.t. said parameters.
DNNs have many degrees of freedom (i.e. weights), and their objective
functions are thus very-high dimensional. For example, ResNet50 has over 23
million trainable parameters. The ”loss landscape” is the same number of
dimensions as the weight space plus 1, as each possible configuration of the
DNN is evaluated for its loss over some number of test examples (i.e. examples
not seen during training).

The first few sections of this paper cover the theoretical background
surrounding the loss landscape and introduce the specific visualization method
used in this work. The loss landscape (also referred to as ”loss surface” and
”objective landscape”) is constructed by calculating the loss of multiple
points in the weight space (i.e. different configurations) of a DNN. Later in
the paper we introduce the lottery ticket hypothesis (LTH) and iterative
magnitude pruning (IMP) by (Frankle & Carbin, 2019), and apply the same loss
visualizations to winning lottery tickets (WLTs) created using IMP.

Figure 1: The loss landscape of a ResNet56, with skip connections removed,
trained on CIFAR10. Skip connections are a useful inductive bias that makes
DNNs both easier to train and achieve lower generalization error. The loss
surface is extremely chaotic and non-convex, which hints at some of the
difficulty in training these types of deep networks. Note that the z-component
is on a natural log scale. View and handle the data yourself here.

All figures in this paper contain a hyperlink in the caption to view the same
data with $LossPlot$ (Bain et al., 2021), an in-browser application built
specifically to visualize these types of surface plots. The projected
contours, radius based clippings, and other settings can be manually
controlled from $LossPlot$. It is designed to be used with a mouse and
keyboard.

##  2 Contributions

  * •

A method of computing the loss landscape that is 100x faster than previous
methods.

  * •

Demonstrate the effect of varying batch size on the loss surface of DNNs. Our
results contradict previously noted correlations of certain visualization
features with trainability and generalization error.

  * •

Contrast the loss landscape of randomly pruned DNNs and winning lottery
tickets produced by iterative magnitude pruning.

##  3 Loss Visualization Background

Figure 2: The loss landscape of a ResNet56 trained on CIFAR10. The only
difference between each subplot is the number of test examples used to
calculate each configuration’s generalization loss. The same random directions
were used across all subplots to ensure a fair comparison. You can handle the
data yourself by clicking this link.

The ability to train DNNs can often be surprising given that they have highly
non-convex structures in their objective landscapes. (Neyshabur et al., 2017)
explore heuristics for characterizing a DNN’s ability to generalize and their
best finding was a combination of sharpness and weight magnitude. Flatness is
the size of the connected region with similar loss, and sharpness is the
antithesis. Flatter minimizers will have larger connected regions of similar
loss around the trained minimizer at the center of each surface plot (i.e.
there will be little relative curvature around the trained solution). Sharp
weight vectors on the other hand have deep crevices immediately surrounding
the solution in the loss space.

Modern DNNs often use rectified activation functions (e.g. ReLU) which
introduce redundancies in the weight space of models. Scaling one layer by a
constant and then scaling the next layer by the inverse results in the same
function. Combining batch norm with rectified activation functions has a
similar effect, because everything is scaled to a common norm, so a relative
comparison between different trained solutions becomes difficult (Dinh et al.,
2017). Both of these introduce what are referred to as ”scaling invariance”.

All visualizations of the loss landscape are generated using the methods from
(Li et al., 2017). Their open-sourced pytorch code evaluates a 2d grid slice
of the weight space centered around the trained minimizer. There are many 2d
grid slices to choose from given the dimensionality of modern DNNs. (Li et
al., 2017) uses a dimensionality reduction technique to choose the slice of
the weight space to plot its loss. It begins with creating two random weight
vectors by sampling a Gaussian distribution $\mathcal{N}$(0, 1).

To fix the problems caused by scaling invariance, (Li et al., 2017) use
”filter-wise normalized directions”. There Gaussian sampled direction vectors
of length 1 are scaled along the components relating to convolutional neural
network (CNN) filters and that subset of the weights norm. I.e. they scale the
component subsets of the random directions using the corresponding magnitude
of filters:

$d_{i,j}\leftarrow\frac{d_{i,j}}{\left\|d_{i,j}\right\|}\left\|\theta_{i,j}\right\|$

$d$ represents 1 of the 2 random directions and $\theta$ are the DNN’s
weights. $d_{i,j}$ represents the j-th filter of the i-th layer of $d$.
$\|\cdot\|$ is the Frobenius norm (Li et al., 2017). Filters are not just
limited to CNNs. A fully connected layer’s filters are the weights connected
to one neuron in the resultant layer.

Figure 3: The same model architecture as in Figure 2 but trained without skip
connections. The number of examples required to get a general notion of the
overall shape is similar, but the landscape has become far more chaotic & non-
convex.

Filter-wise normalization with random directions captures the weighted average
of the principle curvatures (i.e. eigenvalues of the Hessian matrix) and
enables visual comparison of loss surfaces around different trained solutions,
even among different architectures (Li et al., 2017). (Li et al., 2017) claim
that it also causes the flatness of minimizers to negatively correlate with
generalization error. This is contested later in this paper.

(Li et al., 2017) reported that it took hours to produce some of their plots
using multi-GPU machines. They did not report on the resolution of their
plots, but we were able to produce all of this work’s 22 individual surface
plots with a resolution of 125 x 125 in 5 hours and 30 minutes using a single
K40 GPU.

##  4 Creating Loss Visualizations Faster

The full test set was used previously to produce these types of loss surface
plots, yet the general shape of the graph does not change much after a couple
hundred validation examples.

Figure 2 shows the effect of varying the number of test examples to use during
evaluation of each specific weight vector. The network being evaluated is a
ResNet50 (He et al., 2015) trained on CIFAR10. The overall shape changes a lot
for the few first examples. By 10 examples the shape has already taken form,
and going from 1k to 3k test examples has little effect on the plot.

This novel observation can realistically lead to a 100x speedup over
contemporary methods, even more for large datasets. For example, all surface
plots in this paper used a copious random sample of 250 test set images, where
CIFAR10 has 10k examples in its test set. This leads to a 40x reduction in
computation for this dataset.

Figure 3 shows the same evaluation example sweep but using the released
ResNet56 with no skip connections (i.e. noshorts). From the first example the
chaotic and non-convex nature of the loss landscape is already apparent. The
dominant curvatures of the objective landscape surrounding the trained
minimizers is vastly different with and without skip connections.

Figure 4: Low batch sizes produce shallow and flat minimizers. The solutions’
landscapes become progressively deeper and sharper as the batch size
increases. Eventually the trend reverses and the minimizers become shallow and
flat again. This experiment’s data can be viewed with more detail and control
with this link.

Both ResNet56 models were trained by (Li et al., 2017). They can be obtained
from their open-source code here. The preceding experiments used different
random directions than the original authors in order to verify that the
resulting shape is generally consistent across pairs of randomly sampled
directions.

##  5 Effects of Increasing Batch Size

(Keskar et al., 2017) has hypothesized that larger batch sizes create worse
DNNs in part be due to reduced noise in mini-batches, making their weight
trajectories more susceptible to falling into and getting stuck in exotic
basin structures that result in sharp minimizers. This hypothesis was explored
by (Li et al., 2017) and the experiment that follows is a natural continuation
of theirs.

A LeNet5 (Lecun et al., 1998) architecture with dropout and batch-
normalization is trained on FMNIST (Xiao et al., 2017) using Adam (Kingma &
Ba, 2017) and a variable number of mini-batch sizes. Figure 4 highlights the
effects on the underlying loss surface. Given the faster method of computing
these plots we were able to generate 5 high-resolution figures, each with a
batch size between 2 and 16,000. The best performance lies between a batch
size of 160 and 1,600. It would be interesting to continue increasing the
batch size to see if it continually gets worse or if there is a cyclic trend
in performance.

These results contradict the results of (Li et al., 2017), which had
previously suggested that these visualizations created correlations between
model generalization and the sharpness or flatness of the landscape around the
trained minimizer.

##  6 Lottery Ticket Hypothesis Background

The lottery ticket hypothesis (LTH) (Frankle & Carbin, 2019) states that
densely connected DNNs contain sparse sub-network that can exceed the test
accuracy of the original network after training on at most the same number of
instances. These sparse networks are called winning lottery tickets (WLTs) and
do much better than the average random sub-network.

In their work (Frankle & Carbin, 2019) used Algorithm 1 to create winning
lottery tickets. The dense network has a mask $m$ applied element-wise to its
weights: $m\odot\theta$. The mask starts out as all ones. After training
converges the smallest $p$% of the remaining weights are pruned and their
equivalent elements in the mask are set to 0. All remaining weights are re-
initialized to their original random values and training begins again. This
pattern of training, masking, pruning, and re-setting the weights is repeated
until the specified sparsity is reached.

Algorithm 1 Iterative Magnitude Pruning Algorithm

1\. Train network until convergence.
2\. Remove the smallest 10% of remaining weights per
layer and set them to 0.
3\. Re-initialize the remaining weights to their original
values.
4\. Repeat steps 2 and 3 until the desired sparsity is met.

The following notation is adopted from (Frankle & Carbin, 2019):

$P_{m}=\frac{\|m\|_{0}}{|\theta|}$ is the sparsity of $m$, e.g., $P_{m}$ = 25%
when 75% of weights are pruned.

##  7 Loss Landscape of Lottery Tickets

Figure 6 details how the loss landscape evolves as more and more weights are
pruned via Algorithm 1. The LeNet5 architectures are trained on CIFAR10 using
an Adam optimizer (Kingma & Ba, 2017) and mini-batch size of 9.6k. The best
models were obtained using early stopping. After every 35 epochs 10% of the
remaining weights were pruned. A total of 35 pruning iterations occurred,
ending with only 3% of the weights intact. Figure 7 shows the same progression
of $P_{m}$ but using randomly created masks.

Figure 5 shows the learning trends for both WLTs and random tickets. The
results become interesting around $P_{m}$ = 50%. It is here that the
performance gap between IMP and random pruning begins to occur. It continues
to grow all the way through the pruning iterations. By the end of training the
gap in test accuracy is 16%. Note the scale on the bottom-right subplot of
Figure 7, where $P_{m}$ = 4.2%. At first glance the slope might seem non-
trivial, but the z-component’s range is much lesser on this plot. Relative to
the others, this loss surface is very flat. This might be an exotic structure
that prevents training. These ”gradient deserts” seem to be dominated by near
0 curvature, meaning small gradients and weight updates, essentially stalling
training. Independently confirming that this gradient desert exists is
suggested by the author of this research.

Figure 5: Training curves of both randomly pruned tickets and tickets derived
from Algorithm 1. After around $P_{m}$ = 50% the gap in performance shows.
When $P_{m}$ = 3.2% the winning ticket is still performing as well as the
original dense network and generalizes twice as well as the random ticket of
the same sparsity.

Flatness and shallowness in randomly pruned ticket’s loss landscape
projections is associated with poor generalization. The IMP method
consistently produced more convex and sharper minimizers relative to random
masking.

##  8 Discussion

WLTs have been demonstrated to exist in many architecture (Zhou et al., 2020;
Frankle & Carbin, 2019; Yu et al., 2020; Zhang et al., 2021) and in different
task domains like reinforcement learning (RL) and natural language processing
(Yu et al., 2020). Finding WLTs when less than 50% of the network is pruned
seems trivial, but what pragmatic benefit do they offer to practitioners?
Finding these winning tickets still requires a lot of compute and fine-tuning.
If the sample efficiency gains of WLTs can be had from less compute and data,
this could impact fields like Deep RL where sample efficiency is essentially
non-existent.

(Zhou et al., 2020) found that even better than IMP is keeping weights whose
values change by the greatest magnitude, instead of just keeping the largest
magnitude weights. (Frankle & Carbin, 2019) unintentionally foreshadowed this
when noting in their Appendix F that winning tickets’ weights move further
than other weights. (Zhou et al., 2020) also showed that re-initializing the
weights is not as important as retaining the original signs of the weights,
lending even more evidence to the idea that re-initializing to the original
values is not vital to finding WLTs.

Figure 6: Pictured are the WLTs of LeNet5 trained on CIFAR10. The tickets
perform comparably yet the landscapes get flatter and shallower as pruning
continues. The subplot titles are tuples of (mask method, $P_{m}$, test
accuracy). You can view the data yourself here. Figure 7: Objective landscapes
from random lottery tickets of LeNet5 trained on CIFAR10. These tickets
perform much worse relative to the WLTs obtained using IMP. They are also
vastly more shallow. The data is accessible from the web using this link.

(Liu et al., 2019) revised some of the experiments from (Frankle & Carbin,
2019) on pruning larger networks while training on ImageNet. This domain
usually requires a more exhaustive hyper-parameter search to discover WLTs,
but when discovered the results tend to more impressive (Frankle & Carbin,
2019). (Liu et al., 2019) demonstrate that using the more de facto training
regime with a larger learning rate and momentum SGD instead of Adam produces
better results than even the winning tickets, making LTH even less practical.

(Zhang et al., 2021) deduced that 1 hidden-layer neural networks (with some
other assumptions about i.i.d. sampling) should have an enlarged convex region
appear around a guaranteed optimal solution when pruned correctly. It is
difficult to make sense of this work’s results in terms of that hypothesis,
but it might be an interesting future research direction.

As originally noted by (Frankle & Carbin, 2019) their IMP method produces
sparse networks in such a way that GPUs do not benefit. The sparsity allows
more compression, but not faster inference. In part, this is due to the
asynchronous checkpoints that occur while GPUs process matrix calculations in
parallel. Multiplications by 0 in a certain batch might be faster (i.e. fewer
clock cycles) but the slowest multiplication in that batch of operations has
to finish before more calculations can be queued.

(Li et al., 2017) experiments using PCA and found that the majority of
variance in weight updates lies in only a few dimensions. Perhaps these few
very important dimensions are preserved with IMP. It could also be the case
that larger learning rates could dislodge the weights from a gradient desert
and find more amenable points in the weight space, allowing the recovery of
useful training for even randomly masked networks.

The filter-wise normalized random directions method of visualizing the loss
landscape has been shown twice not correlating flatness or sharpness with
generalization error. However, the convexity of the visualization still seems
to correlate with trainability and test performance when the minimizer is deep
enough.

.

## References

  * Bain et al. (2021) Bain, R., Tokarev, M., Kothari, H., and Damineni, R.  Lossplot: A better way to visualize loss landscapes.  _CoRR_ , abs/2111.15133, 2021.  URL https://arxiv.org/abs/2111.15133.
  * Dinh et al. (2017) Dinh, L., Pascanu, R., Bengio, S., and Bengio, Y.  Sharp minima can generalize for deep nets, 2017.
  * Frankle & Carbin (2019) Frankle, J. and Carbin, M.  The lottery ticket hypothesis: Finding sparse, trainable neural networks, 2019.
  * He et al. (2015) He, K., Zhang, X., Ren, S., and Sun, J.  Deep residual learning for image recognition, 2015.
  * Keskar et al. (2017) Keskar, N. S., Mudigere, D., Nocedal, J., Smelyanskiy, M., and Tang, P. T. P.  On large-batch training for deep learning: Generalization gap and sharp minima, 2017.
  * Kingma & Ba (2017) Kingma, D. P. and Ba, J.  Adam: A method for stochastic optimization, 2017.
  * Lecun et al. (1998) Lecun, Y., Bottou, L., Bengio, Y., and Haffner, P.  Gradient-based learning applied to document recognition.  _Proceedings of the IEEE_ , 86(11):2278–2324, 1998.  doi: 10.1109/5.726791.
  * Li et al. (2017) Li, H., Xu, Z., Taylor, G., Studer, C., and Goldstein, T.  Visualizing the loss landscape of neural nets, 2017.
  * Liu et al. (2019) Liu, Z., Sun, M., Zhou, T., Huang, G., and Darrell, T.  Rethinking the value of network pruning, 2019.
  * Neyshabur et al. (2017) Neyshabur, B., Bhojanapalli, S., McAllester, D., and Srebro, N.  Exploring generalization in deep learning, 2017.
  * Xiao et al. (2017) Xiao, H., Rasul, K., and Vollgraf, R.  Fashion-mnist: a novel image dataset for benchmarking machine learning algorithms, 2017.
  * Yu et al. (2020) Yu, H., Edunov, S., Tian, Y., and Morcos, A. S.  Playing the lottery with rewards and multiple languages: lottery tickets in rl and nlp, 2020.
  * Zhang et al. (2021) Zhang, S., Wang, M., Liu, S., Chen, P.-Y., and Xiong, J.  Why lottery ticket wins? a theoretical perspective of sample complexity on sparse neural networks, 2021.  URL https://openreview.net/forum?id=8pz6GXZ3YT.
  * Zhou et al. (2020) Zhou, H., Lan, J., Liu, R., and Yosinski, J.  Deconstructing lottery tickets: Zeros, signs, and the supermask, 2020\.


# The equivalence of GRS codes and EGRS codes

Canze Zhu The author is with the College of Mathematical Science, Sichuan
Normal University, Chengdu Sichuan, 610066 (canzezhu@163.com).

###### Abstract

Generalized Reed-Solomon and extended generalized Reed-Solomon (abbreviation
to GRS and EGRS) codes are the most well-known family of MDS codes with wide
applications in coding theory and practice. Let $\mathbb{F}_{q}$ be the $q$
elements finite field, where $q$ is the power of a prime. For a linear code
$\mathcal{C}$ over $\mathbb{F}_{q}$ with length $2\leq n\leq q$, we prove that
$\mathcal{C}$ is a GRS code if and only if $\mathcal{C}$ is a EGRS code.

###### Index Terms:

Generalized Reed-Solomon codes; Extended generalized Reed-Solomon codes;
Equivalence

##  I Introduction

Let $\mathbb{F}_{q}$ be the $q$ elements finite field, where $q$ is the power
of a prime. An $[n,k,d]$ linear code $\mathcal{C}$ over $\mathbb{F}_{q}$ is a
$k$-dimensional subspace of $\mathbb{F}_{q}^{n}$ with minimum (Hamming)
distance $d$ and length $n$. If the parameters reach the Singleton bound,
namely, $d=n-k+1$, then $\mathcal{C}$ is maximum distance separable (in short,
MDS). MDS codes have various interesting properties and wide applications both
in theoretical and practice, such as, combinatorial designs, finite geometry
[12], data storage and coding for distributed storage systems [1]. The most
two well-known family of MDS codes are that of GRS and EGRS codes, which not
only have nice theoretic properties, but also have been extensively applied in
engineering due to their easy encoding and efficient decoding algorithm.
Similarly, self-dual or small hull codes are another interesting class of
linear codes due to their nice algebraic structure, their wide applications in
cryptography (in particular secret sharing) [4] and constructions of quantum
MDS codes [3, 13].

Therefore, the constructions of the self-dual, or small hull MDS codes have
attracted a lot of attention in recent years. There are a lot of work for
these MDS codes via generalized Reed-Solomon (GRS) codes and their extended
codes[5, 7, 10, 9, 11, 8, 2, 6]. It is worth mentioning that the authors also
distinguish the GRS code and the EGRS code, and presented the similar method
to construct the self-dual or small hull GRS code and EGRS code over
$\mathbb{F}_{q}$ with length less than or equal to $q$. Especially, Fang et.
al prove that all the self-dual EGRS codes over $\mathbb{F}_{q}$ with length
less than or equal to $q$ can be constructed from GRS codes with the same
parameters [6].

In this letter, for a linear code $\mathcal{C}$ over $\mathbb{F}_{q}$ with
length $2\leq n\leq q$, we prove that $\mathcal{C}$ is a GRS code if and only
if $\mathcal{C}$ is a EGRS code. This result implies that there is unnecessary
to distinguish the GRS code and the EGRS code when the length less than or
equal to $q$.

##  II  Main Result

In the following, we review the definitions of the GRS code and the EGRS code,
respectively.

######  Definition 1 ([12], Ch. $10$. $\S 8$ & Ch. $11$. $\S 5$)

For $k,n\in\mathbb{N}$ with $1\leq k\leq n\leq q$, let
$\boldsymbol{v}=(v_{1},\ldots,v_{n})\in(\mathbb{F}_{q}^{*})^{n}$,
$\boldsymbol{\alpha}=(\alpha_{1},\ldots,\alpha_{n})\in\mathbb{F}_{q}^{n}$ with
$\alpha_{i}\neq\alpha_{j}$ $(i\neq j)$ and

$\mathcal{V}_{k}=\\{f(x)~{}|~{}f(x)\in\mathbb{F}_{q}[x]\text{ ~{}and ~{}}\deg
f(x)\leq k-1\\}.$

Then the GRS code is defined as

$\displaystyle\mathcal{GRS}_{k,n}(\boldsymbol{\alpha},\boldsymbol{v})$
$\displaystyle=\\{(v_{1}f({\alpha_{1}}),\ldots,v_{n}f(\alpha_{n}))\big{|}f(x)\in\mathcal{V}_{k}\\}.$

The EGRS code is defined as

$\displaystyle\mathcal{EGRS}_{k,n}(\boldsymbol{\alpha},\boldsymbol{v})\\!=\\!\\{(v_{1}f({\alpha_{1}}),\ldots,v_{n}f(\alpha_{n}),f_{k-1})\big{|}f(x)\\!\in\\!\mathcal{V}_{k}\\},$

where $f_{k-1}$ is a coefficient of $x^{k-1}$ in $f(x)$.

Before giving the main result, we fix the following two nonations.

$\displaystyle\mathrm{GRS}\\!=\\!\big{\\{}\mathcal{C}\\!~{}|\\!~{}\mathcal{C}~{}\text{is
a GRS code over $\mathbb{F}_{q}$ with length~{}}n\geq 2\big{\\}}.$
$\displaystyle\mathrm{EGRS}\\!=\\!\big{\\{}\mathcal{C}\\!~{}|\\!~{}\mathcal{C}~{}\text{is
a EGRS code over $\mathbb{F}_{q}$ with length~{}}n\leq q\big{\\}}.$

The following theorem presents the main result of this paper.

###### Theorem 1

$\mathrm{GRS}=\mathrm{EGRS}.$

The proof of Theorem 1 is given in the next section.

###### Remark 1

It follows from Theorem $1$ that the GRS code and the EGRS code are equivalent
to each other when length $2\leq n\leq q$, which implies that many known
results of GRS codes are aways suitable for EGRS codes directly.

##  III Proofs

The following lemma that will be used to prove that
$\mathrm{GRS}\subseteq\mathrm{EGRS}$.

###### Lemma 1

For $k,n\in\mathbb{N}$ with $1\leq k\leq n\leq q$, let $a\in\mathbb{F}_{q}$,
$\lambda\in\mathbb{F}_{q}^{*}$,
$\boldsymbol{\alpha}=(\alpha_{1},\ldots,\alpha_{n})\in\mathbb{F}_{q}^{n}$ with
$\alpha_{i}\neq\alpha_{j}$ $(i\neq j)$ and
$\boldsymbol{v}=(v_{1},\ldots,v_{n})\in(\mathbb{F}_{q}^{*})^{n}$. If
$\boldsymbol{\beta}=(\alpha_{1}-a,\ldots,\alpha_{n}-a)$ and
$\boldsymbol{w}=(\lambda v_{1},\ldots,\lambda v_{n})$, then

$\displaystyle\mathcal{GRS}_{k,n}(\boldsymbol{\alpha},\boldsymbol{v})=\mathcal{GRS}_{k,n}(\boldsymbol{\beta},\boldsymbol{w}).$

_Proof_. For any
$\big{(}v_{1}f(\alpha_{1}),\ldots,v_{n}f(\alpha_{n})\big{)}\in\mathcal{GRS}_{k,n}(\boldsymbol{\alpha},\boldsymbol{v})$
with $f(x)=\sum\limits_{i=0}^{k-1}f_{i}x^{i}\in\mathbb{F}_{q}[x]$, let
$g(x)=\lambda^{-1}f(x+a)$, then $g(x)\in\mathbb{F}_{q}[x]$ with $\deg g(x)\leq
k-1$. And then, for any $i\in\\{1,\ldots,n\\}$, we have

$\displaystyle v_{i}f(\alpha_{i})$ $\displaystyle=\lambda
v_{i}\big{(}\lambda^{-1}f\big{(}(\alpha_{i}-a)+a\big{)}\big{)}=\lambda
v_{i}g(\alpha_{i}-a),$

that is

$\displaystyle\big{(}v_{1}f(\alpha_{1}),\ldots,v_{n}f(\alpha_{n})\big{)}=\big{(}\lambda
v_{1}g(\alpha_{1}\\!-a),\ldots,\lambda v_{n}g(\alpha_{n}\\!-a)\big{)},$

which leads

$\displaystyle\mathcal{GRS}_{k,n}(\boldsymbol{\alpha},\boldsymbol{v})\subseteq\mathcal{GRS}_{k,n}(\boldsymbol{\beta},\boldsymbol{w}).$

Note that

$\displaystyle\dim(\mathcal{GRS}_{k,n}(\boldsymbol{\alpha},\boldsymbol{v}))=\dim(\mathcal{GRS}_{k,n}(\boldsymbol{\beta},\boldsymbol{w})),$

thus

$\displaystyle\mathcal{GRS}_{k,n}(\boldsymbol{\alpha},\boldsymbol{v})=\mathcal{GRS}_{k,n}(\boldsymbol{\beta},\boldsymbol{w}).$

$\hfill\Box$

###### Remark 2

By taking $a=\alpha_{n}$ and $\lambda=v_{n}^{-1}$ in Lemma 1, then
$\alpha_{n}-a=0$ and $\lambda v_{n}=1$, thus for any GRS code
$\mathcal{GRS}_{k,n}(\boldsymbol{\alpha},\boldsymbol{v})$, we can alway assume
$\alpha_{n}=0$ and $v_{n}=1$ without loss of generality.

Now, $\mathrm{GRS}\subseteq\mathrm{EGRS}$ and
$\mathrm{EGRS}\subseteq\mathrm{GRS}$ are given in Lemmas 2-3, respectively.

###### Lemma 2

$\mathrm{GRS}\subseteq\mathrm{EGRS}.$

_Proof_. By Remark 2, for any $\mathcal{C}\in\mathrm{GRS}$, there exists a
$2\leq n\leq q$,
$\boldsymbol{v}=(v_{1},\ldots,v_{n-1},1)\in(\mathbb{F}_{q}^{*})^{n}$ and
$\boldsymbol{\alpha}=(\alpha_{1},\ldots,\alpha_{n-1},0)\in\mathbb{F}_{q}^{n}~{}\text{with}~{}$
$\alpha_{i}\neq 0,~{}\alpha_{i}\neq\alpha_{j}~{}(i\neq j)$ such that
$\mathcal{C}=\mathcal{GRS}_{k,n}(\boldsymbol{\alpha},\boldsymbol{v})$. Now we
find some $\boldsymbol{\beta},\boldsymbol{w}\in\mathbb{F}_{q}^{n-1}$ such that

$\displaystyle\mathcal{GRS}_{k,n}(\boldsymbol{\alpha},\boldsymbol{v})=\mathcal{EGRS}_{k,n-1}(\boldsymbol{\beta},\boldsymbol{w}).$
(1)

By $\alpha_{i}\neq 0$ $(i=1,\ldots,n-1)$, we can choose

$\boldsymbol{\beta}=(\beta_{1},\ldots,\beta_{n-1})=\big{(}\alpha_{1}^{-1},\ldots,\alpha_{n-1}^{-1}\big{)}$

and

$\boldsymbol{w}=(w_{1},\ldots,w_{n-1})=\big{(}v_{1}\alpha_{1}^{k-1},\ldots,v_{n-1}\alpha_{n-1}^{k-1}\big{)}.$

It is easy to see that $\beta_{i}\neq\beta_{j}$ $(i\neq j)$ and
$\boldsymbol{w}\in(\mathbb{F}_{q}^{*})^{n-1}$. Now we show that $(\ref{R2})$
holds.

For any
$\\!(v_{1}f(\alpha_{1}),\ldots,v_{n-1}f(\alpha_{n-1}),f(0))\\!\in\\!\mathcal{GRS}_{k,n}(\\!\boldsymbol{\alpha},\\!\boldsymbol{v})$
with $f(x)=\sum\limits_{i=0}^{k-1}f_{i}x^{i}\in\mathbb{F}_{q}[x]$, let

$g(x)=\sum\limits_{i=0}^{k-1}f_{i}x^{k-1-i}.$

It is easy to see that $g(x)\in\mathbb{F}_{q}[x]$ with $\deg g(x)\leq k-1.$
Furthermore, the coefficient of $x^{k-1}$ in $g(x)$ is

$g_{k-1}=f_{0}=f(0),$

and for any $j\in\\{1,\ldots,n-1\\}$

$\displaystyle
w_{j}g(\beta_{j})=v_{j}\alpha_{j}^{k-1}\sum\limits_{i=0}^{k-1}f_{i}\alpha_{j}^{i-(k-1)}=v_{j}f(\alpha_{j}).$

Thus

$\displaystyle\big{(}v_{1}f(\alpha_{1}),\ldots,v_{n-1}f(\alpha_{n-1})f(0)\big{)}$
$\displaystyle=$
$\displaystyle\big{(}w_{1}g(\beta_{1}),\ldots,w_{n-1}g(\beta_{n-1}),g_{k-1}\big{)},$

which leads

$\displaystyle\mathcal{GRS}_{k,n}(\boldsymbol{\alpha},\boldsymbol{v})\subseteq\mathcal{EGRS}_{k,n-1}(\boldsymbol{\beta},\boldsymbol{w}).$

Note that

$\dim\big{(}\mathcal{GRS}_{k,n}(\boldsymbol{\alpha},\boldsymbol{v})\big{)}=\dim\big{(}\mathcal{EGRS}_{k,n-1}(\boldsymbol{\beta},\boldsymbol{w})\big{)},$

thus $(\ref{R2})$ holds.

$\hfill\Box$

###### Lemma 3

$\mathrm{EGRS}\subseteq\mathrm{GRS}.$

_Proof_. For any $\mathcal{C}\in\mathrm{EGRS}$, there exists a
$n\\!\leq\\!q-1$,
$\\!\boldsymbol{v}\\!=\\!(v_{1},\ldots,v_{n})\in(\mathbb{F}_{q}^{*})^{n}\\!$
and
$\boldsymbol{\alpha}\\!=\\!(\alpha_{1},\ldots,\alpha_{n})\\!\in\\!\mathbb{F}_{q}^{n}$
with $\alpha_{i}\neq\alpha_{j}~{}(i\neq j)$ such that
$\mathcal{C}=\mathcal{EGRS}_{k,n}(\boldsymbol{\alpha},\boldsymbol{v})$. Now we
find a $\boldsymbol{\beta},\boldsymbol{w}\in\mathbb{F}_{q}^{n+1}$ such that

$\displaystyle\mathcal{GRS}_{k,n+1}(\boldsymbol{\beta},\boldsymbol{w})=\mathcal{EGRS}_{k,n}(\boldsymbol{\alpha},\boldsymbol{v}).$
(2)

By $n\leq q-1$, we know that
$A=\mathbb{F}_{q}\backslash\\{\alpha_{1},\ldots,\alpha_{n}\\}$ is not empty,
by choosing $\gamma\in A$ arbitrarily, let

$\displaystyle\boldsymbol{\beta}$
$\displaystyle=(\beta_{1},\ldots,\beta_{n},\beta_{n+1})$
$\displaystyle=\big{(}(\alpha_{1}-\gamma)^{-1},\ldots,(\alpha_{n}-\gamma)^{-1},0\big{)}$

and

$\displaystyle\boldsymbol{w}=$ $\displaystyle(w_{1},\ldots,w_{n},w_{n+1})$
$\displaystyle=$
$\displaystyle\big{(}v_{1}(\alpha_{1}-\gamma)^{k-1},\ldots,v_{n}(\alpha_{n}-\gamma)^{k-1},1\big{)}.$

It is easy to see that $\beta_{i}\neq\beta_{j}$ $(i\neq j)$ and
$\boldsymbol{w}\in(\mathbb{F}_{q}^{*})^{n+1}$. Now we show that $(\ref{R1})$
holds.

For any
$(v_{1}f(\alpha_{1}),\ldots,v_{n}f(\alpha_{n}),f_{k-1})\in\mathcal{EGRS}_{k,n}(\boldsymbol{\alpha},\boldsymbol{v})$
with $f(x)=\sum\limits_{i=0}^{k-1}f_{i}x^{i}\in\mathbb{F}_{q}[x]$, let

$g(x)=\sum\limits_{i=0}^{k-1}f_{i}(1+\gamma x)^{i}x^{k-1-i}.$

It is easy to see that $g(x)\in\mathbb{F}_{q}[x]$ with $\deg g(x)\leq k-1.$
Furthermore,

$\displaystyle w_{n+1}g(\beta_{n+1})=g(0)=f_{k-1},$

and for any $j\in\\{1,\ldots,n\\}$, we have

$\displaystyle w_{j}g(\beta_{j})$ $\displaystyle=$ $\displaystyle
v_{j}(\alpha_{j}-\gamma)^{k-1}\sum_{i=0}^{k-1}f_{i}(1+\gamma(\alpha_{j}-\gamma)^{-1})^{i}(\alpha_{j}-\gamma)^{-(k-1-i)}$
$\displaystyle=$ $\displaystyle
v_{j}(\alpha_{j}-\gamma)^{k-1}\sum_{i=0}^{k-1}f_{i}(\alpha_{j}(\alpha_{j}-\gamma)^{-1})^{i}(\alpha_{j}-\gamma)^{-(k-1-i)}$
$\displaystyle=$ $\displaystyle v_{j}f(\alpha_{j}),$

that is

$\displaystyle\big{(}w_{1}g(\beta_{1}),\ldots,w_{n}g(\beta_{n}),w_{n+1}g(\beta_{n+1})\big{)}$
$\displaystyle=$
$\displaystyle\big{(}v_{1}f(\alpha_{1}),\ldots,v_{n}f(\alpha_{n}),f_{k-1}\big{)},$

which leads

$\displaystyle\mathcal{EGRS}_{k,n}(\boldsymbol{\alpha},\boldsymbol{v})\subseteq\mathcal{GRS}_{k,n+1}(\boldsymbol{\beta},\boldsymbol{w}).$

Note that

$\dim\big{(}\mathcal{EGRS}_{k,n}(\boldsymbol{\alpha},\boldsymbol{v})\big{)}=\dim\big{(}\mathcal{GRS}_{k,n+1}(\boldsymbol{\beta},\boldsymbol{w})\big{)},$

thus $(\ref{R1})$ holds.

$\hfill\Box$

_Proof of Theorem 1_. The Theorem 1 follows from Lemmas 2-3 directly.

$\hfill\Box$

##  IV Conclusion

In this letter, for a linear code $\mathcal{C}$ with length $2\leq n\leq q$,
we prove that $\mathcal{C}$ is a GRS code if and only if $\mathcal{C}$ is a
EGRS code.

## References

  * [1] Balaji, S. Krishnan, M. Vajha, M. Ramkumar, V. Sasidharan, B. and Kumar, P. Erasure coding for distributed storage: An overview. Science China Information Sciences 61.10 (2018): 1-45.
  * [2] Cao, Meng. MDS Codes With Galois Hulls of Arbitrary Dimensions and the Related Entanglement-Assisted Quantum Error Correction. IEEE Transactions on Information Theory 67.12 (2021): 7964-7984.
  * [3] Calderbank, A. Robert, and Peter W. Shor. Good quantum error-correcting codes exist. Physical Review A 54.2 (1996): 1098.
  * [4] Cramer, R. Daza, V. Gracia, I. Urroz, J. Leander, G. Martí-Farré, J. Padró, C. On codes, matroids, and secure multiparty computation from linear secret-sharing schemes. IEEE Transactions on Information Theory 54.6 (2008): 2644-2657.
  * [5] Fang, Weijun, Xia, Shutao and Fu, Fangwei. Construction of MDS Euclidean self-dual codes via two subsets. IEEE Transactions on Information Theory 67.8 (2021): 5005-5015.
  * [6] Fang, Weijun, Xia, Shutao and Fu, Fangwei. A note on self-dual generalized Reed-Solomon codes. arXiv preprint arXiv:2005.11732 (2020).
  * [7] Fang, Xiaolei, Liu, Meiqing and Luo, Jinquan. New MDS Euclidean self-orthogonal codes. IEEE Transactions on Information Theory 67.1 (2020): 130-137.
  * [8] Fang, Xiaolei, Jin, Renjie, and Luo, Jinquan. New Galois Hulls of GRS Codes and Application to EAQECCs. Cryptography and Communications 14.1 (2022): 145-159.
  * [9] Guo, Guanmin, and Li, Ruihu. Hermitian Self-Dual GRS and Extended GRS Codes. IEEE Communications Letters 25.4 (2020): 1062-1065.
  * [10] Huang, Ziteng, Fang, Weijun and Fu, FangWei. New constructions of MDS self-dual and self-orthogonal codes via GRS codes. arXiv preprint arXiv:2103.11665 (2021).
  * [11] Ning, Yu, Ye, Zuo, Ge, Gennian, Miao, Fuyou, and Zhang Xiande. New Results on Self-Dual Generalized Reed-Solomon Codes. IEEE Transactions on Information Theory 67.11 (2021): 7240-7252.
  * [12] MacWilliams, Florence Jessie, and Neil James Alexander Sloane. The theory of error correcting codes. Vol. 16. Elsevier, 1977.
  * [13] Steane, Andrew M. Simple quantum error-correcting codes. Physical Review A 54.6 (1996): 4741.