IPA to IMAGE model

Prerequisites

In principle, this should work on a computer without a GPU. It will help if you have a lot of RAM.


In [1]:
import imaginet.defn.visual as visual
import imaginet.task


Couldn't import dot_parser, loading of dot files will not be possible.
Using gpu device 0: Tesla K20m

Load the model

(It will take a couple of minutes)


In [2]:
model = imaginet.task.load(path="vis/model.10.zip")


WARNING (theano.gof.compilelock): Overriding existing lock by dead process '27069' (I am process '6511')
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 880, in emit
    stream.write(fs % msg)
IOError: [Errno 5] Input/output error
Logged from file compilelock.py, line 240

Symbol embeddings


In [8]:
reload(visual)
emb = visual.embeddings(model)
print(emb.shape)


(65, 256)

The table of IPA symbols corresponding to the 49 dimensions


In [9]:
symb = visual.symbols(model)
print " ".join(symb.values())


<BEG> <END> <UNK> t uː w ɪ m n ɑː l ʊ k ŋ a ð eə s ɛ f əʊ z ɐ ɹ ə dʒ eɪ p d ɔː aɪ ʃ ɒ v ɔɪ ʌ b i θ iː aʊ h ɜː tʃ j əl iːː ɡ iə ʊə aɪə ʒ aʊə r ɑ̃ t
 ə
 z
 s
 n
 nʲ d
 ŋ
 ɔ m

Let's display the embeddings projected to 2D via PCA


In [22]:
%pylab inline


Populating the interactive namespace from numpy and matplotlib

In [23]:
from sklearn.decomposition import PCA
pca = PCA(n_components=2)
xy = pca.fit_transform(emb)
pylab.rc('font', family='DejaVu Sans')
pylab.figure(figsize=(8,8))
pylab.scatter(xy[:,0], xy[:,1], alpha=0.1)
for j,symb_j in symb.items():
    if symb_j not in ["<BEG>","<END>", "<UNK>"]:
        pylab.text(xy[j,0], xy[j,1], symb_j)


Seems mostly random...

Let's try the same with a Language Model.

Symbol embeddings for a language model


In [24]:
import imaginet.defn.lm
reload(imaginet.defn.lm)
model2 = imaginet.task.load("lm/model.10.zip")
emb2 = imaginet.defn.lm.embeddings(model2)

In [25]:
pca2 = PCA(n_components=2)
xy = pca.fit_transform(emb2)
pylab.rc('font', family='DejaVu Sans')
pylab.figure(figsize=(8,8))
pylab.scatter(xy[:,0], xy[:,1], alpha=0.1)
for j,symb_j in symb.items(): 
    if symb_j not in ["<BEG>","<END>", "<UNK>"]:
        pylab.text(xy[j,0], xy[j,1], symb_j)


There is clear structure in the embeddings for the LM model.

Load MSCOCO validation data


In [7]:
from imaginet.data_provider import getDataProvider
# Adjust the root to point to the directory above data
prov = getDataProvider('coco', root="..")

In [8]:
sents = list(prov.iterSentences(split='val'))

In [9]:
from imaginet.simple_data import phonemes
sents_ipa = [ phonemes(sent) for sent in sents ]

Project sentences to state space


In [10]:
reps = imaginet.task.representation(model, sents_ipa)

Find similar sentences in state space

Compute the pairwise cosine distance matrix.


In [30]:
from scipy.spatial.distance import cdist
distance = cdist(reps, reps, metric='cosine')

Display neighbors for a sentence


In [31]:
import numpy
def neighbors(k, distance=distance, size=5):
    nn =  numpy.argsort(distance[k,:])[1:size]
    print sents[k]['raw'], ''.join(sents_ipa[k])
    for n in nn:
        print u"✔" if sents[n]['imgid']==sents[k]['imgid'] else u"✘", \
        sents[n]['raw'], ''.join(sents_ipa[n])

In [32]:
import random

In [33]:
random.seed(41)
for _ in range(10):
    neighbors(random.randint(0, len(sents)), distance=distance)
    print


A metallic bench on a path in the park. ɐmətalɪkbɛntʃɒnɐpaθɪnðəpɑːk
✘ A bench sitting on a sidewalk in the green and beautiful grass.  ɐbɛntʃsɪtɪŋɒnɐsaɪdwɔːkɪnðəɡɹiːnandbjuːtɪfəlɡɹas
✘ A bench at the park sits off to the side ɐbɛntʃatðəpɑːksɪtsɒftəðəsaɪd
✘ The metal park bench sits next to green grass. ðəmɛtəlpɑːkbɛntʃsɪtsnɛksttəɡɹiːnɡɹas
✘ a bench on a field of green grass  ɐbɛntʃɒnɐfiːldɒvɡɹiːnɡɹas

A dog with a clear cone on its head is watching television. ɐdɒɡwɪðɐkliəkəʊnɒnɪtshɛdɪzwɒtʃɪŋtɛlɪvɪʒən
✔ The dog with a flee collar watches television. ðədɒɡwɪðɐfliːkɒləwɒtʃɪztɛlɪvɪʒən
✔ A dog wearing a protective head piece looking at a TV. ɐdɒɡweəɹɪŋɐpɹətɛktɪvhɛdpiːslʊkɪŋatətiːviː
✔ A dog wearing a protective cone around it's head watching TV. ɐdɒɡweəɹɪŋɐpɹətɛktɪvkəʊnɐɹaʊndɪtshɛdwɒtʃɪŋtiːviː
✘ A cat looks at a dog that is on tv. ɐkatlʊksatədɒɡðatɪzɒntiːviː

Two people in yellow vests and helmets riding horses. tuːpiːpəlɪnjɛləʊvɛstsandhɛlmɪtsɹaɪdɪŋhɔːsɪz
✘ Two people riding on the backs of brown horses. tuːpiːpəlɹaɪdɪŋɒnðəbaksɒvbɹaʊnhɔːsɪz
✘ A man stands on the backs of two running horses. ɐmanstandzɒnðəbaksɒvtuːɹʌnɪŋhɔːsɪz
✘ A man riding a horse guiding other horses.  ɐmanɹaɪdɪŋɐhɔːsɡaɪdɪŋʌðəhɔːsɪz
✘ A man that is sitting on a horse. ɐmanðatɪzsɪtɪŋɒnɐhɔːs

A row of wall mounted urinals under aquariums. ɐɹaʊɒvwɔːlmaʊntɪdjʊəɹɪnəlzʌndəɹɐkweəɹiəmz
✔ A group of urinals next to a large aquarium.  ɐɡɹuːpɒvjʊəɹɪnəlznɛksttʊɐlɑːdʒɐkweəɹiəm
✘ A row of urinals stand on a wall in a bathroom area. ɐɹaʊɒvjʊəɹɪnəlzstandɒnɐwɔːlɪnɐbaθɹuːmeəɹiə
✘ A view of a bunch of urinals with stickers above them. ɐvjuːəvəbʌntʃɒvjʊəɹɪnəlzwɪðstɪkəzəbʌvðɛm
✘ Three urinals mounted to a wall with white little dividers. θɹiːjʊəɹɪnəlzmaʊntɪdtʊɐwɔːlwɪðwaɪtlɪtəldɪvaɪdəz

a group of people are sitting at a table in the park having a picnic ɐɡɹuːpɒvpiːpəlɑːsɪtɪŋatəteɪbəlɪnðəpɑːkhavɪŋɐpɪknɪk
✘ A group of men sitting outdoors and having a picnic. ɐɡɹuːpɒvmɛnsɪtɪŋaʊtdɔːzandhavɪŋɐpɪknɪk
✘ some people sitting at an outdoor table and talking to each other  sʌmpiːpəlsɪtɪŋatɐnaʊtdɔːteɪbəlandtɔːkɪŋtʊiːtʃʌðə
✘ A group of people are all sitting around a table outside ɐɡɹuːpɒvpiːpəlɑːɹɔːlsɪtɪŋɐɹaʊndɐteɪbəlaʊtsaɪd
✘ A group of people gathered around a table outdoors having a meeting. ɐɡɹuːpɒvpiːpəlɡaðədɐɹaʊndɐteɪbəlaʊtdɔːzhavɪŋɐmiːtɪŋ

Three giraffes and a water buffalo in a grassy area. θɹiːdʒɪɹafsandɐwɔːtəbʌfələʊɪnɐɡɹasieəɹiə
✘ Three giraffes grazing in a field with several trees. θɹiːdʒɪɹafsɡɹeɪzɪŋɪnɐfiːldwɪðsɛvɹəltɹiːz
✘ Three giraffes stand in the clearing. by the edge of the grass. θɹiːdʒɪɹafsstandɪnðəkliəɹɪŋbaɪðɪɛdʒɒvðəɡɹas
✘ Three giraffe and a wildebeest in a field. θɹiːdʒɪɹafandɐwaɪldɪbiːstɪnɐfiːld
✘ Four giraffes standing in front of trees on a grassy field.  fɔːdʒɪɹafsstandɪŋɪnfɹʌntɒvtɹiːzɒnɐɡɹasifiːld

on overturned bus on the side of the road  ɒnəʊvətɜːndbʌsɒnðəsaɪdɒvðəɹəʊd
✘ A bus stopped on the side of the road. ɐbʌsstɒptɒnðəsaɪdɒvðəɹəʊd
✘ An abandoned bus on the sid eof the rode ɐnɐbandəndbʌsɒnðəsɪdiːɒfðəɹəʊd
✘ A bus that is on the side of the road. ɐbʌsðatɪzɒnðəsaɪdɒvðəɹəʊd
✘ A bus is sitting on the side of the road. ɐbʌsɪzsɪtɪŋɒnðəsaɪdɒvðəɹəʊd

A young woman riding a horse holding a flag ɐjʌŋwʊmənɹaɪdɪŋɐhɔːshəʊldɪŋɐflaɡ
✔ a woman riding a horse while holding a flag ɐwʊmənɹaɪdɪŋɐhɔːswaɪlhəʊldɪŋɐflaɡ
✔ A girl riding a horse holding a red flag ɐɡɜːlɹaɪdɪŋɐhɔːshəʊldɪŋɐɹɛdflaɡ
✘ A lady on a horse of some sort. ɐleɪdiɒnɐhɔːsɒvsʌmsɔːt
✘ Person rides on a horse while holding a large flag on the field pɜːsənɹaɪdzɒnɐhɔːswaɪlhəʊldɪŋɐlɑːdʒflaɡɒnðəfiːld

a male tennis player playing tennis on a green and blue court ɐmeɪltɛnɪspleɪəpleɪɪŋtɛnɪsɒnɐɡɹiːnandbluːkɔːt
✘ A man standing on top of a blue tennis court holding a racquet. ɐmanstandɪŋɒntɒpəvəbluːtɛnɪskɔːthəʊldɪŋɐɹakeɪ
✘ A tennis player is on a blue and green court. ɐtɛnɪspleɪəɹɪzɒnɐbluːandɡɹiːnkɔːt
✘ a male tennis player in a blue shirt is playing tennis ɐmeɪltɛnɪspleɪəɹɪnɐbluːʃɜːtɪzpleɪɪŋtɛnɪs
✘ A male tennis player in action on the court. ɐmeɪltɛnɪspleɪəɹɪnakʃənɒnðəkɔːt

A woman gazes at her phone while standing along a street. ɐwʊmənɡeɪzɪzathɜːfəʊnwaɪlstandɪŋɐlɒŋɐstɹiːt
✔ A woman is looking down at her cell phone near a street. ɐwʊmənɪzlʊkɪŋdaʊnathɜːsɛlfəʊnniəɹɐstɹiːt
✘ A woman on her cellphone standing on the sidewalk in a city.  ɐwʊmənɒnhɜːsɛlfəʊnstandɪŋɒnðəsaɪdwɔːkɪnɐsɪti
✘ Woman talking on cell phone on sidewalk with pedestrians nearby. wʊməntɔːkɪŋɒnsɛlfəʊnɒnsaɪdwɔːkwɪðpədɛstɹiənzniəbaɪ
✔ A woman in a coat using her cellphone in the city. ɐwʊmənɪnɐkəʊtjuːzɪŋhɜːsɛlfəʊnɪnðəsɪti

State space for lower layers

We can also access the states in the whole set of layers using the pile function. We'll do it in batches to avoid memory problems on the GPU.


In [36]:
reload(visual)
reps2 = []
for i in range(0,len(sents_ipa),512):
    r = [ ri[-1] for ri in imaginet.task.pile(model, sents_ipa[i:i+512], batch_size=256) ]
    reps2.extend(r)

In [37]:
reps2 = numpy.array(reps2)
distance1 = cdist(reps2[:,1,:], reps2[:,1,:], metric='cosine')
distance0 = cdist(reps2[:,0,:], reps2[:,0,:], metric='cosine')

In [38]:
%reset_selective reps2 # Free memory


Once deleted, variables cannot be recovered. Proceed (y/[n])?  y

What is encoded in different layers

The prediction is that the lowest layer will mostly encode phonetic similarity, while the top layer will encode mostly semantic similarity. Let's see if this is the case.


In [39]:
random.seed(41)
for _ in range(10):
    i = random.randint(0, len(sents))
    print "Layer 1"
    neighbors(i, distance=distance0, size=2)
    print "Layer 2"
    neighbors(i, distance=distance1, size=2)
    print "Layer 3"
    neighbors(i, distance=distance, size=2)
    print


Layer 1
A metallic bench on a path in the park. ɐmətalɪkbɛntʃɒnɐpaθɪnðəpɑːk
✘ A man riding a bicycle on a path in a park. ɐmanɹaɪdɪŋɐbaɪsɪkəlɒnɐpaθɪnɐpɑːk
Layer 2
A metallic bench on a path in the park. ɐmətalɪkbɛntʃɒnɐpaθɪnðəpɑːk
✘ A person sitting on a bench in a park. ɐpɜːsənsɪtɪŋɒnɐbɛntʃɪnɐpɑːk
Layer 3
A metallic bench on a path in the park. ɐmətalɪkbɛntʃɒnɐpaθɪnðəpɑːk
✘ A bench sitting on a sidewalk in the green and beautiful grass.  ɐbɛntʃsɪtɪŋɒnɐsaɪdwɔːkɪnðəɡɹiːnandbjuːtɪfəlɡɹas

Layer 1
A dog with a clear cone on its head is watching television. ɐdɒɡwɪðɐkliəkəʊnɒnɪtshɛdɪzwɒtʃɪŋtɛlɪvɪʒən
✘ A cat sitting on the floor watching television. ɐkatsɪtɪŋɒnðəflɔːwɒtʃɪŋtɛlɪvɪʒən
Layer 2
A dog with a clear cone on its head is watching television. ɐdɒɡwɪðɐkliəkəʊnɒnɪtshɛdɪzwɒtʃɪŋtɛlɪvɪʒən
✔ The dog with a flee collar watches television. ðədɒɡwɪðɐfliːkɒləwɒtʃɪztɛlɪvɪʒən
Layer 3
A dog with a clear cone on its head is watching television. ɐdɒɡwɪðɐkliəkəʊnɒnɪtshɛdɪzwɒtʃɪŋtɛlɪvɪʒən
✔ The dog with a flee collar watches television. ðədɒɡwɪðɐfliːkɒləwɒtʃɪztɛlɪvɪʒən

Layer 1
Two people in yellow vests and helmets riding horses. tuːpiːpəlɪnjɛləʊvɛstsandhɛlmɪtsɹaɪdɪŋhɔːsɪz
✘ Two women in english riding outfits on top of horses. tuːwɪmɪnɪnɪŋɡlɪʃɹaɪdɪŋaʊtfɪtsɒntɒpɒvhɔːsɪz
Layer 2
Two people in yellow vests and helmets riding horses. tuːpiːpəlɪnjɛləʊvɛstsandhɛlmɪtsɹaɪdɪŋhɔːsɪz
✘ A man riding a horse guiding other horses.  ɐmanɹaɪdɪŋɐhɔːsɡaɪdɪŋʌðəhɔːsɪz
Layer 3
Two people in yellow vests and helmets riding horses. tuːpiːpəlɪnjɛləʊvɛstsandhɛlmɪtsɹaɪdɪŋhɔːsɪz
✘ Two people riding on the backs of brown horses. tuːpiːpəlɹaɪdɪŋɒnðəbaksɒvbɹaʊnhɔːsɪz

Layer 1
A row of wall mounted urinals under aquariums. ɐɹaʊɒvwɔːlmaʊntɪdjʊəɹɪnəlzʌndəɹɐkweəɹiəmz
✘ A fork is laying on an empty plate with crumbs. ɐfɔːkɪzleɪɪŋɒnɐnɛmptipleɪtwɪðkɹʌmz
Layer 2
A row of wall mounted urinals under aquariums. ɐɹaʊɒvwɔːlmaʊntɪdjʊəɹɪnəlzʌndəɹɐkweəɹiəmz
✘ Three urinals mounted to a wall with white little dividers. θɹiːjʊəɹɪnəlzmaʊntɪdtʊɐwɔːlwɪðwaɪtlɪtəldɪvaɪdəz
Layer 3
A row of wall mounted urinals under aquariums. ɐɹaʊɒvwɔːlmaʊntɪdjʊəɹɪnəlzʌndəɹɐkweəɹiəmz
✔ A group of urinals next to a large aquarium.  ɐɡɹuːpɒvjʊəɹɪnəlznɛksttʊɐlɑːdʒɐkweəɹiəm

Layer 1
a group of people are sitting at a table in the park having a picnic ɐɡɹuːpɒvpiːpəlɑːsɪtɪŋatəteɪbəlɪnðəpɑːkhavɪŋɐpɪknɪk
✘ A group of men sitting outdoors and having a picnic. ɐɡɹuːpɒvmɛnsɪtɪŋaʊtdɔːzandhavɪŋɐpɪknɪk
Layer 2
a group of people are sitting at a table in the park having a picnic ɐɡɹuːpɒvpiːpəlɑːsɪtɪŋatəteɪbəlɪnðəpɑːkhavɪŋɐpɪknɪk
✘ A group of men sitting outdoors and having a picnic. ɐɡɹuːpɒvmɛnsɪtɪŋaʊtdɔːzandhavɪŋɐpɪknɪk
Layer 3
a group of people are sitting at a table in the park having a picnic ɐɡɹuːpɒvpiːpəlɑːsɪtɪŋatəteɪbəlɪnðəpɑːkhavɪŋɐpɪknɪk
✘ A group of men sitting outdoors and having a picnic. ɐɡɹuːpɒvmɛnsɪtɪŋaʊtdɔːzandhavɪŋɐpɪknɪk

Layer 1
Three giraffes and a water buffalo in a grassy area. θɹiːdʒɪɹafsandɐwɔːtəbʌfələʊɪnɐɡɹasieəɹiə
✘ An old blue truck is on a grassy area. ɐnəʊldbluːtɹʌkɪzɒnɐɡɹasieəɹiə
Layer 2
Three giraffes and a water buffalo in a grassy area. θɹiːdʒɪɹafsandɐwɔːtəbʌfələʊɪnɐɡɹasieəɹiə
✘ Two birds and two giraffes stand on a grassy area. tuːbɜːdzandtuːdʒɪɹafsstandɒnɐɡɹasieəɹiə
Layer 3
Three giraffes and a water buffalo in a grassy area. θɹiːdʒɪɹafsandɐwɔːtəbʌfələʊɪnɐɡɹasieəɹiə
✘ Three giraffes grazing in a field with several trees. θɹiːdʒɪɹafsɡɹeɪzɪŋɪnɐfiːldwɪðsɛvɹəltɹiːz

Layer 1
on overturned bus on the side of the road  ɒnəʊvətɜːndbʌsɒnðəsaɪdɒvðəɹəʊd
✘ Two old fashioned buses parked on the side of the road. tuːəʊldfaʃəndbʌsɪzpɑːktɒnðəsaɪdɒvðəɹəʊd
Layer 2
on overturned bus on the side of the road  ɒnəʊvətɜːndbʌsɒnðəsaɪdɒvðəɹəʊd
✘ A bus that is on the side of the road. ɐbʌsðatɪzɒnðəsaɪdɒvðəɹəʊd
Layer 3
on overturned bus on the side of the road  ɒnəʊvətɜːndbʌsɒnðəsaɪdɒvðəɹəʊd
✘ A bus stopped on the side of the road. ɐbʌsstɒptɒnðəsaɪdɒvðəɹəʊd

Layer 1
A young woman riding a horse holding a flag ɐjʌŋwʊmənɹaɪdɪŋɐhɔːshəʊldɪŋɐflaɡ
✔ a woman riding a horse while holding a flag ɐwʊmənɹaɪdɪŋɐhɔːswaɪlhəʊldɪŋɐflaɡ
Layer 2
A young woman riding a horse holding a flag ɐjʌŋwʊmənɹaɪdɪŋɐhɔːshəʊldɪŋɐflaɡ
✔ a woman riding a horse while holding a flag ɐwʊmənɹaɪdɪŋɐhɔːswaɪlhəʊldɪŋɐflaɡ
Layer 3
A young woman riding a horse holding a flag ɐjʌŋwʊmənɹaɪdɪŋɐhɔːshəʊldɪŋɐflaɡ
✔ a woman riding a horse while holding a flag ɐwʊmənɹaɪdɪŋɐhɔːswaɪlhəʊldɪŋɐflaɡ

Layer 1
a male tennis player playing tennis on a green and blue court ɐmeɪltɛnɪspleɪəpleɪɪŋtɛnɪsɒnɐɡɹiːnandbluːkɔːt
✘ A tennis player is on a blue and green court. ɐtɛnɪspleɪəɹɪzɒnɐbluːandɡɹiːnkɔːt
Layer 2
a male tennis player playing tennis on a green and blue court ɐmeɪltɛnɪspleɪəpleɪɪŋtɛnɪsɒnɐɡɹiːnandbluːkɔːt
✘ A male tennis player in action on the court. ɐmeɪltɛnɪspleɪəɹɪnakʃənɒnðəkɔːt
Layer 3
a male tennis player playing tennis on a green and blue court ɐmeɪltɛnɪspleɪəpleɪɪŋtɛnɪsɒnɐɡɹiːnandbluːkɔːt
✘ A man standing on top of a blue tennis court holding a racquet. ɐmanstandɪŋɒntɒpəvəbluːtɛnɪskɔːthəʊldɪŋɐɹakeɪ

Layer 1
A woman gazes at her phone while standing along a street. ɐwʊmənɡeɪzɪzathɜːfəʊnwaɪlstandɪŋɐlɒŋɐstɹiːt
✘ Several cars are traveling on a city street while a bicyclist waits to cross the street. sɛvɹəlkɑːzɑːtɹavəlɪŋɒnɐsɪtistɹiːtwaɪlɐbaɪsɪklɪstweɪtstəkɹɒsðəstɹiːt
Layer 2
A woman gazes at her phone while standing along a street. ɐwʊmənɡeɪzɪzathɜːfəʊnwaɪlstandɪŋɐlɒŋɐstɹiːt
✔ A woman is looking down at her cell phone near a street. ɐwʊmənɪzlʊkɪŋdaʊnathɜːsɛlfəʊnniəɹɐstɹiːt
Layer 3
A woman gazes at her phone while standing along a street. ɐwʊmənɡeɪzɪzathɜːfəʊnwaɪlstandɪŋɐlɒŋɐstɹiːt
✔ A woman is looking down at her cell phone near a street. ɐwʊmənɪzlʊkɪŋdaʊnathɜːsɛlfəʊnniəɹɐstɹiːt

Tracing the evolution of states


In [11]:
import imaginet.tracer

In [12]:
tr = imaginet.tracer.Tracer()

In [13]:
tr.fit(reps)


Embedding
Fitting PCA

In [14]:
tr.proj.explained_variance_


Out[14]:
array([ 16.24318886,  14.13266277], dtype=float32)

Use espeak to convert graphemes to phonemes


In [15]:
from subprocess import check_output
def espeak(words):
    return phon(check_output(["espeak", "-q", "--ipa=3",
                        '-v', 'en',
                        words]).decode('utf-8'))
def phon(inp):
    return [ ph.replace(u"ˈ","") for word in inp.split() for ph in word.split("_") ]

In [19]:
%pylab inline --no-import-all
def trace(orths, tracer=tr, model=model, eos=True, size=(6,6)):
    ipas = [ espeak(orth) for orth in orths ]
    states = imaginet.task.states(model, ipas)
    pylab.figure(figsize=size)
    tracer.traces(ipas, states, eos=eos)


Populating the interactive namespace from numpy and matplotlib

Plot traces of example sentences


In [20]:
trace(["A bowl of salad","A plate of pizza","A brown dog", "A black cat"])



In [21]:
trace(["a cow", "a baby cow","a tiny baby cow"])



In [25]:
orths = ["A cow","A baby","A tiny"]
ipas = [ espeak(orth) for orth in orths ]
states = imaginet.task.states(model, ipas)
states[0][0] - states[1][0]


Out[25]:
array([ -3.86097794e-03,   1.67058073e-02,   3.69312614e-03, ...,
        -7.43026733e-02,   5.37785781e-05,   1.41334906e-03], dtype=float32)

In [23]:
trace(["some food on a table","a computer on a table","a table with food"])
pylab.axis('off')


Out[23]:
(0.0, 1.6000000000000001, -0.5, 4.0)

In [24]:
trace(["a bear in a cage", "a brown bear in the zoo","a teddy bear on a chair"])



In [ ]: