# Self-Replicating and Self-Employed Smart Contract on Ethereum Blockchain

Atsushi Masumori1, Norihiro Maruyama1 Takashi Ikegami1

1Alternative Machine Inc.
(This paper was originally written in 2022 for submission to ALIFE 2022.)

## Introduction

In this research, we implement evolving creatures on blockchain. Blockchain is
the underlying technology for cryptocurrencies such as Bitcoin (Nakamoto,
(2008)), and has received much attention in recent years. Blockchain is a
robust distributed ledger that uses consensus algorithms such as Proof-of-Work
(Nakamoto, (2008)) and Proof-of-Stake (Sunny King, (2012)) to approve
transactions in a decentralized manner, making malicious tampering extremely
difficult. The local approvers are incentivized in order to receive rewards,
and as long as this incentive persists, the robust blockchain will never stop.

Ethereum, one of the blockchains, can be seen as an unstoppable computer which
shared by users around the world that can run Turing-complete programs. In
order to run any program on Ethereum, Ether (currency on Ethereum) is
required. In other words, Ether can be seen as a kind of energy in the
Ethereum world. Ethereum has already transitioned from PoW to PoS, and it is
expected that power consumption will decrease by 99.95 percent, making
progress towards resolving environmental issues caused by blockchain.

We developed self-replicating agents who earn the energy by themselves to
replicate them, on the Ethereum blockchain. This self-replicating agent lives
for the purpose of preserving its own offspring. The agent needs Ether in
order to perform some action, and when ether is gone, there is nothing left to
do. The agents can create non-fungible tokens (NFTs: ERC-721) which is a
decentralized proof of digital token. The created NFTs are associated with the
agents (e.g., image of their phenotype), and gain Ether each time these NFTs
are sold. When a certain amount of Ether is accumulated, the agent replicates
itself and leaves offspring.

Each self-replication results in a genetic mutation that causes the offspring
to differ in appearance and behavior from its parents. The agents that become
popular and sell NFTs at a high price can acquire more Ether and leave more
offspring. Selection pressure is exerted such that an agent who becomes
popular and sells NFTs at a high price can acquire more Ether and produce more
offspring. Thus our system is a kind of interactive evolutionary computation
(Secretan et al., (2011); Clune and Lipson, (2011)) on the blockchain.

Figure 1: Variations of phenotype of agents.

## Implementation

### Individuals

In Ethereum, there are two types of accounts : Externally Owned Account (EOA)
and contract account. EOA is an account used by human, while a contract
account is an account for a contract which is a unit of program on Ethereum.
Like EOA, contract account has an Ethereum address and can trade Ether
associated with this address, so contract itself can hold Ether. This contract
corresponds to the agent in our model.

### Self-Replication

There are two main ways to duplicate a contract on Ethereum: factory pattern
and minimal proxy pattern (EIP-1167). In factory pattern, it consists of two
contracts, factory contract and product contract. In this case, the product
contract itself does not create a contract, but the factory contract generates
a new contract and copies the variables of the product contract.

Figure 2: Overview of the system. Users call proxy contracts which represent
agents and store genome information. The proxy contracts use functions of
logic contract (e.g, self-replication, creating NFT) via delegatecall.

EIP-1167 is a standard for inexpensive and easy contract copying with a
minimum of code. In a case of minimal proxy pattern based on EIP-1167, the
original contract creates a minimal proxy contract, and the proxy contract
uses functions of the original contract via delegatecall, where the storage of
the proxy contract can be changed by the functions of the original code.

We implemented the replicating contract using the minimal proxy pattern based
on EIP1167 (Fig. 2), because, as far as we tested, this method was the least
expensive method to replicate in our case. In our implementation, the original
contract itself is also proxy contract which uses functions of logic contract
via delegatecall (Fig. 2), for reducing computational cost.

In Ethereum, a contract cannot be the starting point of a transaction, in
other words, the contract cannot initiate its actions completely
spontaneously. The main solution to this is using withdraw pattern. Namely,
the contract cashes back to the EOA that called the contract’s function, an
amount greater than the computational cost paid by the EOA. Importantly, the
EOA does not decide the content of the execution, but the contract can decide
the content by its own program. A simple implementation of this method is to
prepare a function for the withdraw pattern and reward the user who executes
the function when the pre-determined conditions are met. The agent poked from
the outside by this withdraw pattern will replicate, if it possesses
sufficient Ether.

### Self-Employment

The agents must earn Ether in order to replicate. To earn Ether, they create
their NFTs, which they sell and receive Ether in return. The NFT is associated
with the digital data of the agent’s phenotype, which is represented as an
image in Scalable Vector Graphics (SVG) format (Fig. 1). In many cases, the
data itself is kept outside from the blockchain and link to the NFT, but we
implemented the data of NFT itself also to be computed on the blockchain.

Figure 3: A tree diagram of the evolving result in Rinkeby test network. At
the present time, there are 225 agents.

The development of phenotype from the agent’s genome was implemented based on
Richard Dawkins’ Biomorph (Dawkins, (1989)), which generates a tree structure
by executing a recursive function. The implementation here used a modified
version of the original Biomorph. We mainly added color elements and line
thickness elements to the original one. A developmental algorithm using
recursive functions, like Biormorph or L-system (Lindenmayer, (1968)), can
generate complex structures with little information and functions. Such kinds
of method are compatible with a full on-chain implementation on Ethereum,
since it requires a lot of cost to store information on the blockchain.

At present, major NFTs markets such as Opensea do not allow contracts to
automatically and directly list their products for sale. Therefore, we
implemented our agents to be able to sell their NFTs directly to EOA by
executing a function to purchase NFTs with Ether at a price higher than the
agent’s determined price. We developed a website (life.alternativemachine.com)
to simplify the user’s interaction with the contract, but the user can also
communicate directly with the agent without this website.

We implemented the original agent but once we deploy the contract on Ethereum,
we are not in control of them, but are on equal footing with them, providing
them with services such as websites for sales and executing withdraw patterns.
Third parties can also provide services to the agent and receive compensation
for them, just as we do.

## Discussion

We deployed this evolving system on Ethereum Rinkeby test network in 2022 for
evaluating the system, and we confirmed this system works well (Fig. 3). We
will deploy the finalized version of the system on Ethereum main network until
the conference.

The goal of this project is to implement artificial agents that lives for
itself, not as a tool for humans, in the open cyber space connected to the
real world. This implementation is the first step, and it is also an
experiment for open-ended evolution, which is an important theme in artificial
life. In the future, we plan to develop a protocol for artificial agents in
the blockchain, or original blockchain for them, and also provide various
services for the artificial agents so that an ecosystem or economy can be
created among the agents.

## References

  * Clune and Lipson, (2011) Clune, J. and Lipson, H. (2011).  Evolving 3d objects with a generative encoding inspired by developmental biology.  SIGEVOlution, 5(4):2–12.
  * Dawkins, (1989) Dawkins, R. (1989).  The evolution of evolvability.  In Artificial life, pages 201–220. Routledge.
  * Lindenmayer, (1968) Lindenmayer, A. (1968).  Mathematical models for cellular interactions in development i. filaments with one-sided inputs.  Journal of Theoretical Biology, 18(3):280–299.
  * Nakamoto, (2008) Nakamoto, S. (2008).  Bitcoin: A peer-to-peer electronic cash system.
  * Secretan et al., (2011) Secretan, J., Beato, N., D’Ambrosio, D. B., Rodriguez, A., Campbell, A., Folsom-Kovarik, J. T., and Stanley, K. O. (2011).  Picbreeder: A Case Study in Collaborative Evolutionary Exploration of Design Space.  Evolutionary Computation, 19(3):373–403.
  * Sunny King, (2012) Sunny King, S. N. (2012).  Ppcoin: Peer-to-peer crypto-currency with proof-of-stake.


# Meta-DRN: Meta-Learning for 1-Shot Image Segmentation

Atmadeep Banerjee  Dept. of Computer Science
Birla Institute of Technology and Science, Pilani
Pilani, India
<EMAIL_ADDRESS>
###### Abstract

Modern deep learning models have revolutionized the field of computer vision.
But, a significant drawback of most of these models is that they require a
large number of labelled examples to generalize properly. Recent developments
in few-shot learning aim to alleviate this requirement. In this paper, we
propose a novel lightweight CNN architecture for 1-shot image segmentation.
The proposed model is created by taking inspiration from well-performing
architectures for semantic segmentation and adapting it to the 1-shot domain.
We train our model using 4 meta-learning algorithms that have worked well for
image classification and compare the results. For the chosen dataset, our
proposed model has a 70% lower parameter count than the benchmark, while
having better or comparable mean IoU scores using all 4 of the meta-learning
algorithms.

##  I Introduction

Modern deep learning models have made tremendous progress in the field of
computer vision, even outperforming humans in some cases. However, a
significant drawback of most of these models is their dependency on large
amounts of labelled data. Recent progress in semi-supervised and few-shot
learning algorithms is helping to alleviate this. The simplest idea that can
be used in a situation where training data is scarce, is transfer learning[1].
In several computer vision tasks, fine-tuning models pretrained on the
ImageNet[2] dataset has been shown to perform well, even with a small dataset
size. However, in many situations, especially where the dataset to be fine-
tuned on differs significantly from the pretraining dataset, transfer learning
does not work too well[3]. The second approach is semi-supervised learning
which can be used in situations where plenty of unlabelled data is available
but labelled data is scarce. But in situations where extra unlabelled data is
not available either, few-shot learning is the viable option.

The problem of few-shot learning can be formulated as a meta-learning problem.
In such a scenario, a meta-learning model is trained on discrete tasks where,
each task forms a data point for the meta-model. A task is defined as a
combination of a support set $S$ and query set $Q$. $S$ has a small number of
support examples $Is$ along with their labels $Ls$. $Q$ is a set of query
examples $Iq$ and their labels $Lq$. The model has to predict $Lq$ given
$<Is,Ls,Iq>$. 1-shot learning is an extreme case of few-shot learning where
the support set $S$ is restricted to have a single training sample.

In practice, 1-shot learning is meaningful to use for testing the viability of
a deep learning an approach without incurring the large cost of acquiring a
labelled dataset. By extension, it is also meaningful for 1-shot models to be
lightweight in terms of memory and computational power in order to minimize
cost. For this reason we propose a model for 1-shot segmentation that is 70%
smaller than the dataset benchmark in terms of parameter count, and can be
trained in a shorter time with a lower memory requirement.

The objective of this paper is two-fold. First we propose our novel
lightweight model architecture for 1-shot image segmentation. Next we compare
the results upon training using 4 gradient-based meta-learning algorithms that
have shown good results in image classification. The chosen algorithms are
MAML[4], Meta-SGD[5], FOMAML[4] and Reptile[6]. We use the FSS-1000 dataset[7]
for training. We made the choice of using gradient-based meta-learning
approaches instead of a metric-based approach as used in the FSS-1000
benchmark because it allowed us to train lightweight models, while retaining
comparable accuracy. The chosen algorithms all belong to the MAML[4] family of
algorithms. These algorithms use a meta model to initialize a learner with a
set of weights such that, given a task, the learner can converge in a minimal
amount of training iterations. Our network architecture is designed to be
lightweight. To ensure this, we use a model with minimal downsampling of input
feature maps. We use dilated convolutions, instead of downsampling to increase
the receptive field of our convolution layers. This approach allows us our
model to be much smaller than an encoder-decoder architecture, while still
being comparably performant.

##  II Related Work

Image segmentation is an extensively studied field in computer vision. The
task requires dense pixel-wise predictions, given an input image. Encoder-
decoder architectures are mostly commonly used for this task. The U-Net
architecture, designed by Ronneberger et al.[8] is a very popular architecture
for image segmentation. It improves over standard encoder-decoder
architectures by incorporating skip connections between the encoder and
decoder, allowing deep models to be trained. Standard CNN models like
Resnet[9] are often used as encoders in U-Net based architectures. These CNN
models perform successive downsampling of feature maps to discard irrelevant
information. This also has the effect of increasing the effective receptive
field of the convolution kernels in deeper layers. While this is an effective
approach for image classification, for dense pixel wise predictions, this
discarding of information is harmful, especially when the object of interest
is not spatially dominant.

Yu and Koltun suggest in [10] that standard the task of dense predictions is
structurally different from image classification. They show that dilated
convolutions perform better than standard CNNs on dense prediction tasks. In
[11] Yu et al. introduce Dilated Residual Networks, which are a modification
of standard ResNets[9] using dilated convolutions instead of downsampling of
feature maps. This architecture achieved much better performance on tasks like
image segmentation and object localization. We use the idea proposed in this
paper and adapt it to the few shot setting.

Most existing work in few-shot segmentation uses variants of branched CNN
architectures[12, 13, 14, 15] or relational networks[16]. In general these
methods rely on using learnable modules to find the similarity between support
and query images. Although meta-learning has seen a lot of success with few-
shot image classification, frequently reaching state-of-the-art results, these
techniques have not been as extensively used for segmentation. Some examples
include [17, 18]. We use the FSS-1000[7] dataset for our models. This dataset
is designed specifically for few-shot segmentation. Most previous works made
use of the PASCAL-5i dataset[19], which is a few-shot version of the PASCAL-
VOC dataset[20]. PASCAL-5i only has 20 classes, which is far lower than
FSS-1000. Li et al. argue in [7] that approaches trained on only 20 classes
may suffer from strong bias. A drawback of this dataset is that most images
contain a single object. Because of this, we have specifically visualized some
test images that contain multiple objects in Figure 4.

##  III Studied Algorithms

MAML: MAML trains a meta-learner to learn how to initialize a learner with a
suitable set of initial weights $\theta$. When the learner is presented with
the support set of a new task, it can converge in a small amount of gradient-
descent iterations.

$\theta^{\prime}=\theta-\alpha.\nabla\mathcal{L}_{train(\mathcal{T})}(\theta)$
(1)

Here $\alpha$ is a predefined constant. The meta-learner is trained to improve
its initialization of learner weights using the query set(or test set) of
training tasks.

$\theta=\theta-\beta.\nabla\mathcal{L}_{test(\mathcal{T})}(\theta^{\prime})$
(2)

Here $\beta$ is the scalar learning rate for the meta-learner. The meta-
learner can be trained using any gradient based optimization algorithm like
Adam.

FOMAML: As is evident from equation (2) MAML requires calculating a second-
order derivative when optimizing the meta-learner weights, which leads to a
significant increase in training time. Finn et al. show that even without
calculating second-order derivatives, performance comparable to MAML can be
reached for image classification and reinforcement learning. This algorithm is
called First Order approximation to MAML or FOMAML. In FOMAML, equation (2) is
modified by assuming that the gradient term in the calculation of
$\theta^{\prime}$ is independent of $\theta$.

Meta-SGD: The third algorithm we train our model on is Meta-SGD[5]. This
algorithm is same as MAML except for the fact that the learning rates $\alpha$
for each parameter in the learner is not a constant. Instead it is a trainable
parameter that is also optimized by the meta-learner. The meta-learner
therefore has control over not only the initialization, but also the learning
rates of the parameters of the learner. In practice, this means that Meta-SGD
shows faster convergence, higher accuracy and lower sensitivity to
hyperparameters than MAML. The learner’s training equation is same as that of
MAML, except for $\alpha$ not being a constant. The meta-learner is trained
according to the following modified equation

$(\theta,\alpha)=(\theta,\alpha)-\beta.\nabla_{(\theta,\alpha)}\mathcal{L}_{test(\mathcal{T})}(\theta^{\prime})$
(3)

Like MAML, Meta-SGD also requires calculation of second-order derivatives and
therefore has a higher training time and memory requirement.

Reptile: The final algorithm we use to train our model is Reptile[6]. Reptile
is similar to FOMAML in that it does not require calculation of second-order
derivatives. The Reptile meta-learner also learns to initialize the weights
$\theta$ of the learner. The learner performs $k(>1)$ gradient updates on the
support set of a task.

$\begin{multlined}\textrm{repeat $k$ times:}\\\
\theta^{\prime}=\theta-\alpha.\nabla\mathcal{L}_{train(\mathcal{T})}(\theta)\end{multlined}\textrm{repeat
$k$ times:}\\\
\theta^{\prime}=\theta-\alpha.\nabla\mathcal{L}_{train(\mathcal{T})}(\theta)$
(4)

When training the meta-learner, Reptile does not need the training tasks to
have a query set. It uses the difference between the final weights of the
learner $\theta^{\prime}$ and the initial weights $\theta$ to train the meta-
learner according to the following equation.

$\theta=\theta+\beta.(\theta^{\prime}-\theta)$ (5)

Nichol et al. also suggest that the term $\theta^{\prime}-\theta$ can be
treated as the gradient for the meta-learner and it can be trained using any
gradient-descent algorithm like Adam.

Figure 1: The proposed model architecture.

##  IV Proposed Architecture

Figure 2: The activations of a MAML Meta-DRN on 3 test tasks. For each layer
the feature map with the highest mean activation value is visualized

As already discussed, successive downsampling of feature maps is not a good
choice for tasks requiring dense predictions and the alternative of using
dilated convolutions to increase the receptive field is much more suitable.
Also, since U-Net based models perform a learned upsampling of feature maps
using deconvolutions, a network that performs less reduction of the feature
map’s size in the encoder, will have to use lesser parameters for upsampling
in the decoder. A network with dilated convolutions is therefore capable of
being more lightweight than a U-Net based model.

Our proposed architecture is depicted in Figure 1. It consists of a head,
followed by 3 residual blocks (with skip connections), two degridding
layers[11] and a final upsampling layer. The residual blocks are similar to
those in ResNet-18 and ResNet-34, but has fewer layers and makes use of
dilated convolutions. The upsampling layer makes use of a sub-pixel
convolution. The feature map with highest activation, formed after passing
through each layer group is visualized in Figure 2.

Head: The head consists of two 3x3 convolution layers, with each layer being
followed by a batch normalization layer[21] and a leaky relu[22] non
linearity. The first layer has a stride of 2 and 16 filters. The second layer
has 64 filters.

ResBlock-1: The head is followed by ResBlock-1. It is similar to a normal
ResNet residual block, having a stride 2 convolution followed by a normal
1-dilated convolution. All convolution layers have 128 filters.

ResBlock-2: In ResBlock-2, there is a 1-dilated convolution, followed by a
2-dilated convolution. All convolution layers have 256 filters. If the first
convolution layer had performed a strided convolution, the effective receptive
field of the second layer would have been doubled. Instead of performing a
strided convolution and reducing the feature map size, we double the dilation
of the second convolution layer to have the same effect. We can represent this
by:

$(\mathcal{G}^{2}_{2}*_{2}f^{2}_{2})(\mathbf{p})=\sum_{\mathbf{a+2b=p}}\mathcal{G}^{2}_{2}(\mathbf{a})f^{2}_{2}(\mathbf{b})$
(6)

Similar to the notation used in [11], here $\mathcal{G}^{l}_{i}$ indicates the
$i$th filter of the $l$th ResBlock. $f^{l}_{i}$ indicates the filter
associated with layer $\mathcal{G}^{l}_{i}$.

ResBlock-3: In ResBlock-3, there is a 2-dilated convolution followed by a
4-dilated convolution. All convolution layers have 512 filters. The first
convolution layer of the this block would have double its receptive field had
we performed a strided convolution in ResBlock-2. To have the same effect,
this layer also has a 2-dilated convolution. Similarly, the second layer of
the ResBlock-3, would have had 4 times its receptive field if there were
strided convolutions in both ResBlock-2 and ResBlock-3. To have this same
effect, we make the convolution 4-dilated.

$(\mathcal{G}^{3}_{1}*_{2}f^{3}_{1})(\mathbf{p})=\sum_{\mathbf{a+2b=p}}\mathcal{G}^{3}_{1}(\mathbf{a})f^{3}_{1}(\mathbf{b})$
(7)

$(\mathcal{G}^{3}_{2}*_{4}f^{3}_{2})(\mathbf{p})=\sum_{\mathbf{a+4b=p}}\mathcal{G}^{3}_{2}(\mathbf{a})f^{3}_{2}(\mathbf{b})$
(8)

Degrid: As observed by Yu et al.[11], using dilated convolutions have a
tendency to introduce grid artifacts in the feature maps. These are removed by
using a degridding layers consisting of convolution layers with successively
smaller dilation. The degridding layers in our architecture consists of two
successive 3x3 convolutions with 2-dilation followed by 1-dilation. Both have
512 filters.

TABLE I: Results Setting | mIoU (thresh = 0.5) | mIoU (thresh = 0.35) |  | Time per epoch
---
(min)
Parameter Count
FSS-1000 | 73.47 | - | 48:00* | 32.83M
Meta-DRN, MAML | $75.17\pm 0.12$ | $75.19\pm 0.11$ | 28:40 | 9.56M
Meta-DRN, FOMAML | $68.21\pm 0.18$ | $68.14\pm 0.01$ | 18:09
Meta-DRN, Meta-SGD | $75.89\pm 0.39$ |  76.63 $\pm$ 0.32 | 29:32
Meta-DRN, Reptile | $64.29\pm 0.22$ | $63.98\pm 0.18$ | 51:09

Upsample: A deviation from the original DRN model in our architecture, apart
from model depth, is the use of a sub-pixel convolution layer[23] for the
upsampling of the final feature maps to create the ouput. The original DRN
model uses either of bilinear upsampling or a deconvolution layer. In our
model, sub-pixel convolution was chosen because it is faster for upsampling
than standard deconvolution, while still having the advantage of learned
upsampling. It performs a convolution in the low resolution space, and
upsamples the result with a phase shift operation. Also, a sub-pixel
convolution operation is mathematically equivalent to a deconvolution while
still being faster.

##  V Experiments

###  V-A Dataset

The FSS-1000 dataset[7] consists of images belonging 1000 classes, with 10
images per class. The dataset has 10 labelled images per class, with dense
pixel-wise labels. Out of the 1000 classes 240 has been marked by the authors
as the test set. Out of the 760 train classes, 700 are used for training and
60 for validation. Final results are reported on the 240 test classes.

###  V-B Training

All our models are trained in 1-shot setting for 200 epochs. Basic
augmentations, including flip, rotate, zoom, warp and lighting transforms were
applied to the images in the 700 training classes. Cross entropy loss was used
to train all the models. The evaluation metric is mean Intersection over
Union(IoU). For predicted and ground-truth masks, IoU becomes the area of
intersection divided by the sum of areas of both masks reduced by area of
union.

$IoU=\frac{Pred*Targ}{Pred+Targ-Pred*Targ}$ (9)

All training runs are performed on an RTX 2080 GPU and the time per epoch on
this GPU is reported for comparison. Note that the time per epoch for FSS-1000
model is based on our implementation. The training details for each algorithm
are as follows:

For MAML, the meta batch size was set to 5. The learning rate for the
learner(fast weights) was initialized to 1e-3. The number of train steps for
the learner(fast weights) were set to 1. The learning rate for the meta-
learner was initialized to 1e-3 and set to halve every time the IoU plateaued
for more than 8 epochs. Cosine annealing and One Cycle learning rate schedules
were also tried but found to not significantly affect performance. AdamW[24]
optimizer was used for training the meta-learner. We found that the weight
decay introduced by AdamW to be beneficial. These setting were same for FOMAML
and Meta-SGD.

For Reptile, the meta batch size was set to 8. The learning rates for the
learner was initialized to 1e-3. The number of train steps for the learner
(hyperparameter $k$) was set to 5. The meta-learner’s learning rate was
initialized to 3e-2 and set to linearly reduced to 3e-5 over 200 epochs. AdamW
optimizer was used to train the meta-learner.

###  V-C Results

The feature maps produced by each layer group in our model is visualized in
Figure 2. An added advantage of not downsampling the feature maps, is that the
shape of the target object is always clearly visible and the model’s actions
are easier to humanly interpret. The model steadily increases the separation
between the object and the background as the feature maps progress through the
layers. The blurry output of the degridding layers is due to the nature of
upsampling performed by the sub-pixel convolution layer.

Figure 3: Visualization of a few validation images after 10 epochs of
training. The top row is Meta-SGD model and bottom is Reptile. Figure 4:
Results of 1-shot segmentation on some classes from the FSS-1000 test set. The
images with green masks are the support images and ones with red masks are
predictions on the corresponding query sets. The dataset classes from top to
bottom are pizza, eagle, ferrari911, american_alligator, and bat.

The training for all 4 our meta-models were rather unstable and there were
sudden drops and subsequent recovery in the validation IoU metric over the
course of training. This phenomenon has been observed before for MAML in image
classification. We observe that the non-thresholded mIoU is more stable than
thresholded mIoU and hence a better validation metric to monitor.

For image classification, Finn et al. have noted that FOMAML has a negligible
loss in performance compared to MAML. Reptile too is able to reach similar
accuracies as FOMAML and MAML. We observe that this is not the case for our
chosen model architecture, where the second-order algorithms, MAML and Meta-
SGD, outperformed FOMAML and Reptile. Although the second-order algorithms
were approximately 50% slower, they performed around 10% better on the mIoU
metric. As noted by Antoniou et al.[25], the performance of MAML is strongly
dependent on model architecture. Changes to the model architecture may be able
to bring the first-order algorithms closer to second-order ones.

We observe that the Reptile model tends to produce final outputs with high
pixel values while Meta-SGD tends to produce outputs with lower pixel values.
In Figure 3, we visualize a few validation images from both Meta-SGD and
Reptile after 10 epochs of training. All masks are generated by setting
threshold to $0.5$. Meta-SGD tends to generate smaller masks that partially
cover the target objects while Reptile generates larger masks that cover more
than target objects. This effect persists even after the end of training. The
mean IoU for Meta-SGD goes up on lowering the threshold from 0.5 while it goes
down for Reptile. In Table 1 we show the results for a lower threshold of
0.35(arbitrarily selected) along with the standard threshold of 0.5. MAML
outputs tend to be in-between Reptile and Meta-SGD.

The final results for our approach along with the existing benchmark on the
FSS-1000 dataset has been shown in Table 1. We present our results with 95%
confidence intervals. Our best performing model was MetaDRN trained with Meta-
SGD. Its expected mIoU value on the FSS-1000 test was 76.63%, which is 3.16%
higher than the benchmark of 73.47%.

##  VI Conclusion

In this paper we propose a lightweight CNN architecture for 1-shot image
segmentation. The model is based on dilated residual networks[11] and uses
dilated convolutions in place of downsampling. Unlike the original DRN model
we use a sub-pixel convolution in place of deconvolution for upsampling the
final feature maps.

We train our model on the FSS-1000 using 4 meta-learning algorithms that work
well for image classification and get results comparable to the existing
benchmark. We also find that for our architecture, 2nd-order meta-learning
algorithms perform better than 1st-order algorithms, in the same settings.

## References

  * [1] C. Tan, F. Sun, T. Kong, W. Zhang, C. Yang, and C. Liu, “A survey on deep transfer learning,” _ArXiv_ , vol. abs/1808.01974, 2018.
  * [2] O. Russakovsky, J. Deng, H. Su, J. Krause, S. Satheesh, S. Ma, Z. Huang, A. Karpathy, A. Khosla, M. Bernstein, A. C. Berg, and L. Fei-Fei, “ImageNet Large Scale Visual Recognition Challenge,” _International Journal of Computer Vision (IJCV)_ , vol. 115, no. 3, pp. 211–252, 2015.
  * [3] M. Raghu, C. Zhang, J. M. Kleinberg, and S. Bengio, “Transfusion: Understanding transfer learning for medical imaging,” in _NeurIPS_ , 2019\.
  * [4] C. Finn, P. Abbeel, and S. Levine, “Model-agnostic meta-learning for fast adaptation of deep networks,” in _ICML_ , 2017.
  * [5] Z. Li, F. Zhou, F. Chen, and H. Li, “Meta-sgd: Learning to learn quickly for few shot learning,” _ArXiv_ , vol. abs/1707.09835, 2017.
  * [6] A. Nichol, J. Achiam, and J. Schulman, “On first-order meta-learning algorithms,” _CoRR_ , vol. abs/1803.02999, 2018. [Online]. Available: http://arxiv.org/abs/1803.02999
  * [7] T. Wei, X. Li, Y. P. Chen, Y.-W. Tai, and C.-K. Tang, “Fss-1000: A 1000-class dataset for few-shot segmentation,” _ArXiv_ , vol. abs/1907.12347, 2019.
  * [8] O. Ronneberger, P. Fischer, and T. Brox, “U-net: Convolutional networks for biomedical image segmentation,” _ArXiv_ , vol. abs/1505.04597, 2015.
  * [9] K. He, X. Zhang, S. Ren, and J. Sun, “Deep residual learning for image recognition,” _2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR)_ , pp. 770–778, 2016.
  * [10] F. Yu and V. Koltun, “Multi-scale context aggregation by dilated convolutions,” _CoRR_ , vol. abs/1511.07122, 2015.
  * [11] F. Yu, V. Koltun, and T. A. Funkhouser, “Dilated residual networks,” _2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR)_ , pp. 636–644, 2017.
  * [12] K. Rakelly, E. Shelhamer, T. Darrell, A. A. Efros, and S. Levine, “Conditional networks for few-shot semantic segmentation,” in _ICLR_ , 2018.
  * [13] C. Zhang, G. Lin, F. Liu, R. Yao, and C. Shen, “Canet: Class-agnostic segmentation networks with iterative refinement and attentive few-shot learning,” _2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)_ , pp. 5212–5221, 2019.
  * [14] Y. Yang, F. Meng, H. Li, Q. Wu, X. Xu, and S. Chen, “A new local transformation module for few-shot segmentation,” in _MMM_ , 2020.
  * [15] K. Wang, J. H. Liew, Y. Zou, D. Zhou, and J. Feng, “Panet: Few-shot image semantic segmentation with prototype alignment,” _2019 IEEE/CVF International Conference on Computer Vision (ICCV)_ , pp. 9196–9205, 2019.
  * [16] F. Sung, Y. Yang, L. Zhang, T. Xiang, P. H. S. Torr, and T. M. Hospedales, “Learning to compare: Relation network for few-shot learning,” _2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition_ , pp. 1199–1208, 2018.
  * [17] P. Tian, Z. Wu, L. Qi, L. Wang, Y. Shi, and Y. Gao, “Differentiable meta-learning model for few-shot semantic segmentation,” _ArXiv_ , vol. abs/1911.10371, 2019.
  * [18] Z. Cao, T. Zhang, W. Diao, Y. Zhang, X. Lyu, K. Fu, and X. an Sun, “Meta-seg: A generalized meta-learning framework for multi-class few-shot semantic segmentation,” _IEEE Access_ , vol. 7, pp. 166 109–166 121, 2019.
  * [19] A. Shaban, S. Bansal, Z. Liu, I. Essa, and B. Boots, “One-shot learning for semantic segmentation,” _ArXiv_ , vol. abs/1709.03410, 2017.
  * [20] M. Everingham, L. V. Gool, C. K. I. Williams, J. M. Winn, and A. Zisserman, “The pascal visual object classes (voc) challenge,” _International Journal of Computer Vision_ , vol. 88, pp. 303–338, 2009.
  * [21] S. Ioffe and C. Szegedy, “Batch normalization: Accelerating deep network training by reducing internal covariate shift,” _ArXiv_ , vol. abs/1502.03167, 2015.
  * [22] A. L. Maas, “Rectifier nonlinearities improve neural network acoustic models,” 2013.
  * [23] W. Shi, J. Caballero, F. Huszár, J. Totz, A. P. Aitken, R. Bishop, D. Rueckert, and Z. Wang, “Real-time single image and video super-resolution using an efficient sub-pixel convolutional neural network,” _2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR)_ , pp. 1874–1883, 2016.
  * [24] I. Loshchilov and F. Hutter, “Fixing weight decay regularization in adam,” _ArXiv_ , vol. abs/1711.05101, 2017.
  * [25] A. Antoniou, H. A. Edwards, and A. J. Storkey, “How to train your maml,” _ArXiv_ , vol. abs/1810.09502, 2019.
  * [26] A. Santoro, D. Raposo, D. G. T. Barrett, M. Malinowski, R. Pascanu, P. W. Battaglia, and T. P. Lillicrap, “A simple neural network module for relational reasoning,” in _NIPS_ , 2017.
  * [27] T. Hu, P. Yang, C. Zhang, G. Yu, Y. Mu, and C. G. M. Snoek, “Attention-based multi-context guiding for few-shot semantic segmentation,” in _AAAI_ , 2019\.
  * [28] K. Nguyen and S. Todorovic, “Feature weighting and boosting for few-shot segmentation,” _2019 IEEE/CVF International Conference on Computer Vision (ICCV)_ , pp. 622–631, 2019.
  * [29] X. Zhang, Y. Wei, Y. Yang, and T. Huang, “Sg-one: Similarity guidance network for one-shot semantic segmentation,” _ArXiv_ , vol. abs/1810.09091, 2018\.
  * [30] M. Siam, B. N. Oreshkin, and M. Jägersand, “Amp: Adaptive masked proxies for few-shot segmentation,” _2019 IEEE/CVF International Conference on Computer Vision (ICCV)_ , pp. 5248–5257, 2019.
  * [31] Z. Dong, R. Zhang, X. Shao, and H. Zhou, “Multi-scale discriminative location-aware network for few-shot semantic segmentation,” _2019 IEEE 43rd Annual Computer Software and Applications Conference (COMPSAC)_ , vol. 2, pp. 42–47, 2019.
  * [32] L. Biewald, “Experiment tracking with weights and biases,” 2020, software available from wandb.com. [Online]. Available: https://www.wandb.com/
  * [33] J. Howard and S. Gugger, “fastai: A layered api for deep learning,” _ArXiv_ , vol. abs/2002.04688, 2020.