<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.gacrc.uga.edu/index.php?action=history&amp;feed=atom&amp;title=DyNet-Teaching</id>
	<title>DyNet-Teaching - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.gacrc.uga.edu/index.php?action=history&amp;feed=atom&amp;title=DyNet-Teaching"/>
	<link rel="alternate" type="text/html" href="https://wiki.gacrc.uga.edu/index.php?title=DyNet-Teaching&amp;action=history"/>
	<updated>2026-05-23T02:24:39Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.7</generator>
	<entry>
		<id>https://wiki.gacrc.uga.edu/index.php?title=DyNet-Teaching&amp;diff=16221&amp;oldid=prev</id>
		<title>Shtsai: Created page with &quot;Category:TeachingCategory:SoftwareCategory:Bioinformatics    === Category ===  Bioinformatics  === Program On ===  Teaching  === Version ===  2.0.3  === Author / D...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.gacrc.uga.edu/index.php?title=DyNet-Teaching&amp;diff=16221&amp;oldid=prev"/>
		<updated>2019-08-14T17:53:21Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&lt;a href=&quot;/wiki/Category:Teaching&quot; title=&quot;Category:Teaching&quot;&gt;Category:Teaching&lt;/a&gt;&lt;a href=&quot;/wiki/Category:Software&quot; title=&quot;Category:Software&quot;&gt;Category:Software&lt;/a&gt;&lt;a href=&quot;/wiki/Category:Bioinformatics&quot; title=&quot;Category:Bioinformatics&quot;&gt;Category:Bioinformatics&lt;/a&gt;    === Category ===  Bioinformatics  === Program On ===  Teaching  === Version ===  2.0.3  === Author / D...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:Teaching]][[Category:Software]][[Category:Bioinformatics]]  &lt;br /&gt;
&lt;br /&gt;
=== Category ===&lt;br /&gt;
&lt;br /&gt;
Bioinformatics&lt;br /&gt;
&lt;br /&gt;
=== Program On ===&lt;br /&gt;
&lt;br /&gt;
Teaching&lt;br /&gt;
&lt;br /&gt;
=== Version ===&lt;br /&gt;
&lt;br /&gt;
2.0.3&lt;br /&gt;
&lt;br /&gt;
=== Author / Distributor ===&lt;br /&gt;
[https://github.com/clab/dynet DyNet]&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
DyNet is a neural network library developed by Carnegie Mellon University and many others. It is written in C++ (with bindings in Python) and is designed to be efficient when run on either CPU or GPU, and to work well with networks that have dynamic structures that change for every training instance. &lt;br /&gt;
More details at [https://github.com/clab/dynet DyNet]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Running Program ===&lt;br /&gt;
 &lt;br /&gt;
Also refer to [[Running Jobs on the teaching cluster]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Python 3 version with CPU support only&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
*Version 2.0.3, installed in /usr/local/apps/gb/dynet/2.0.3-Python-3.6.4-foss-2018a&lt;br /&gt;
&lt;br /&gt;
To use this version of dynet, please first load the module with&lt;br /&gt;
&amp;lt;pre class=&amp;quot;gscript&amp;quot;&amp;gt;&lt;br /&gt;
ml DyNet/2.0.3-Python-3.6.4-foss-2018a&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
This module will automatically load Python/3.6.4-foss-2018a and the foss/2018a toolchain.&lt;br /&gt;
&lt;br /&gt;
Example script (myDyNetScript.py) using DyNet for solving the “xor” problem ([https://dynet.readthedocs.io/en/latest/tutorials_notebooks/tutorial-1-xor.html DyNet Tutorial]):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;gscript&amp;quot;&amp;gt;&lt;br /&gt;
import dynet as dy&lt;br /&gt;
&lt;br /&gt;
# define the parameters&lt;br /&gt;
m = dy.ParameterCollection()&lt;br /&gt;
W = m.add_parameters((8,2))&lt;br /&gt;
V = m.add_parameters((1,8))&lt;br /&gt;
b = m.add_parameters((8))&lt;br /&gt;
&lt;br /&gt;
# renew the computation graph&lt;br /&gt;
dy.renew_cg()&lt;br /&gt;
&lt;br /&gt;
# create the network&lt;br /&gt;
x = dy.vecInput(2) # an input vector of size 2.&lt;br /&gt;
output = dy.logistic(V*(dy.tanh((W*x)+b)))&lt;br /&gt;
# define the loss with respect to an output y.&lt;br /&gt;
y = dy.scalarInput(0) # this will hold the correct answer&lt;br /&gt;
loss = dy.binary_log_loss(output, y)&lt;br /&gt;
&lt;br /&gt;
# create training instances&lt;br /&gt;
def create_xor_instances(num_rounds=2000):&lt;br /&gt;
    questions = []&lt;br /&gt;
    answers = []&lt;br /&gt;
    for round in range(num_rounds):&lt;br /&gt;
        for x1 in 0,1:&lt;br /&gt;
            for x2 in 0,1:&lt;br /&gt;
                answer = 0 if x1==x2 else 1&lt;br /&gt;
                questions.append((x1,x2))&lt;br /&gt;
                answers.append(answer)&lt;br /&gt;
    return questions, answers&lt;br /&gt;
&lt;br /&gt;
questions, answers = create_xor_instances()&lt;br /&gt;
&lt;br /&gt;
# train the network&lt;br /&gt;
trainer = dy.SimpleSGDTrainer(m)&lt;br /&gt;
&lt;br /&gt;
total_loss = 0&lt;br /&gt;
seen_instances = 0&lt;br /&gt;
for question, answer in zip(questions, answers):&lt;br /&gt;
    x.set(question)&lt;br /&gt;
    y.set(answer)&lt;br /&gt;
    seen_instances += 1&lt;br /&gt;
    total_loss += loss.value()&lt;br /&gt;
    loss.backward()&lt;br /&gt;
    trainer.update()&lt;br /&gt;
    if (seen_instances &amp;gt; 1 and seen_instances % 100 == 0):&lt;br /&gt;
        print(&amp;quot;average loss is:&amp;quot;,total_loss / seen_instances)&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Sample job submission script (sub.sh) to run this sample script (myDyNetScript.py):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;gscript2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt;!/bin/bash&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt;SBATCH --job-name=&amp;lt;u&amp;gt;dynetjob&amp;lt;/u&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt;SBATCH --partition=batch&amp;lt;br&amp;gt;        &lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt;SBATCH --mail-type=ALL&amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt;SBATCH --mail-user=&amp;lt;u&amp;gt;username@uga.edu&amp;lt;/u&amp;gt;&amp;lt;br&amp;gt;  &lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt;SBATCH --ntasks=&amp;lt;u&amp;gt;1&amp;lt;/u&amp;gt;&amp;lt;br&amp;gt;   &lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt;SBATCH --mem=&amp;lt;u&amp;gt;4gb&amp;lt;/u&amp;gt;&amp;lt;br&amp;gt;    &lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt;SBATCH --time=&amp;lt;u&amp;gt;08:00:00&amp;lt;/u&amp;gt;&amp;lt;br&amp;gt;   &lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt;SBATCH --output=&amp;lt;u&amp;gt;dynetjob&amp;lt;/u&amp;gt;.%j.out&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt;SBATCH --error=&amp;lt;u&amp;gt;dynetjob&amp;lt;/u&amp;gt;.%j.err&amp;lt;br&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
cd $SLURM_SUBMIT_DIR&amp;lt;br&amp;gt;&lt;br /&gt;
ml DyNet/2.0.3-Python-3.6.4-foss-2018a&amp;lt;br&amp;gt;    &lt;br /&gt;
python3 myDyNetScript.py&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
where myDyNetScript.py is the sample script name and it needs to be replaced by the script and options you want to use.&lt;br /&gt;
&lt;br /&gt;
In the real submission script, at least all the above underlined values need to be reviewed or to be replaced by the proper values.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Sample job submission command:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;gcommand&amp;quot;&amp;gt;&lt;br /&gt;
sbatch sub.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
[https://dynet.readthedocs.io/en/latest/index.html DyNet Doc]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
Version 2.0.3 installed with &amp;#039;&amp;#039;&amp;#039;pip install dynet&amp;#039;&amp;#039;&amp;#039; using Python/3.6.4-foss-2018a on August 14, 2019.&lt;br /&gt;
&lt;br /&gt;
=== System ===&lt;br /&gt;
64-bit Linux&lt;/div&gt;</summary>
		<author><name>Shtsai</name></author>
	</entry>
</feed>