## Jupyter at Bryn Mawr College

Public notebooks: /services/public/dblank / Experiments

# 1. Calysto Scheme¶

## 1.1 Scheme Types¶

In [27]:
(map (lambda (n . x) '1) '(2 3 4 5))

Out[27]:
(1 1 1 1)
In [28]:
"hello"

Out[28]:
"hello"
In [29]:
'hello

Out[29]:
hello
In [30]:
%%python

def myfunc(a, b):
return a ** b

retval = myfunc

Out[30]:
<function myfunc at 0x7f827ac6c9d8>
In [31]:
(define myfunc _)

In [32]:
(myfunc 2 4)

Out[32]:
16

## 1.2 Python¶

### 1.2.1 Matplotlib¶

Calysto Scheme can use Python data and modules.

In [7]:
%matplotlib notebook

(import "matplotlib")

Out[7]:
(matplotlib)
In [8]:
(import-as "matplotlib.pyplot" 'plt)

Out[8]:
(plt)
In [9]:
(plt.plot (vector 1 2 3))
(plt.savefig "myfig")
;;(display (plt.show))

In [10]:
(display (plt.bar (range 3) '(1 2 3)))

<Container object of 3 artists>
In [11]:
(plt.show)


### 1.2.2 Conx¶

Conx is a Python library that uses a GPU for computation for running neural networks (built on Theano).

In [1]:
(import "conx")

Out[1]:
(conx)
In [2]:
(define network (conx.Network 2 2 1))

In [16]:
;; should be able to use lists; limitation with numpy?
;; in any event, we avoid the issue and use Python's list (eg, vector)

(define inputs (vector (vector (vector 0 0) (vector 0))
(vector (vector 0 1) (vector 1))
(vector (vector 1 0) (vector 1))
(vector (vector 1 1) (vector 1))))

In [17]:
(network.set_inputs inputs)

In [18]:
(network.train)

--------------------------------------------------
Training for max trails: 5000 ...
Epoch: 0 TSS error: 0.852345552557 %correct: 0.0
Epoch: 500 TSS error: 0.694100790472 %correct: 0.0
Epoch: 1000 TSS error: 0.162915098795 %correct: 0.25
Epoch: 1500 TSS error: 0.0378934737976 %correct: 0.75
Epoch: 2000 TSS error: 0.0185897371133 %correct: 0.75
--------------------------------------------------
Epoch: 2102 TSS error: 0.0167087325778 %correct: 1.0