add a4 annotation

This commit is contained in:
chongjiu.jin
2019-11-29 09:46:32 +08:00
parent 4880899c9d
commit 4f44285ab3
68 changed files with 452865 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
import torch
from torch import nn
import numpy as np
def rnn_forwarder(rnn, inputs, seq_lengths):
"""
:param rnn: RNN instance
:param inputs: FloatTensor, shape [batch, time, dim] if rnn.batch_first else [time, batch, dim]
:param seq_lengths: LongTensor shape [batch]
:return: the result of rnn layer,
"""
batch_first = rnn.batch_first
# assume seq_lengths = [3, 5, 2]
# 对序列长度进行排序(降序), sorted_seq_lengths = [5, 3, 2]
# indices 为 [1, 0, 2], indices 的值可以这么用语言表述
# 原来 batch 中在 0 位置的值, 现在在位置 1 上.
# 原来 batch 中在 1 位置的值, 现在在位置 0 上.
# 原来 batch 中在 2 位置的值, 现在在位置 2 上.
sorted_seq_lengths, indices = torch.sort(seq_lengths, descending=True)
# 如果我们想要将计算的结果恢复排序前的顺序的话,
# 只需要对 indices 再次排序(升序),会得到 [0, 1, 2],
# desorted_indices 的结果就是 [1, 0, 2]
# 使用 desorted_indices 对计算结果进行索引就可以了.
_, desorted_indices = torch.sort(indices, descending=False)
# 对原始序列进行排序
if batch_first:
inputs = inputs[indices]
else:
inputs = inputs[:, indices]
packed_inputs = nn.utils.rnn.pack_padded_sequence(inputs,
sorted_seq_lengths.cpu().numpy(),
batch_first=batch_first)
res, state = rnn(packed_inputs)
padded_res, _ = nn.utils.rnn.pad_packed_sequence(res, batch_first=batch_first)
# 恢复排序前的样本顺序
if batch_first:
desorted_res = padded_res[desorted_indices]
else:
desorted_res = padded_res[:, desorted_indices]
return desorted_res
if __name__ == "__main__":
bs = 3
max_time_step = 6
feat_size = 7
hidden_size = 7
seq_lengths = torch.tensor([3, 5, 2]).long()
rnn = nn.GRU(input_size=feat_size,
hidden_size=hidden_size, batch_first=True, bidirectional=False)
x=torch.tensor(np.random.randn(bs, max_time_step, feat_size),dtype=torch.float32)
# x = torch.tensor(torch.FloatTensor(bs, max_time_step, feat_size).clone().detach())
print("x shape",x.shape)
using_packed_res = rnn_forwarder(rnn, x, seq_lengths)
print(using_packed_res)
# 不使用 pack_paded, 用来和上面的结果对比一下.
not_packed_res, _ = rnn(x)
print(not_packed_res)

View File

@@ -0,0 +1,851 @@
Last year I showed these two slides so that demonstrate that the arctic ice cap, which for most of the last three million years has been the size of the lower 48 states, has shrunk by 40 percent.
But this understates the seriousness of this particular problem because it doesn't show the thickness of the ice.
The arctic ice cap is, in a sense, the beating heart of the global climate system.
It expands in winter and contracts in summer.
The next slide I show you will be a rapid fast-forward of what's happened over the last 25 years.
The permanent ice is marked in red.
As you see, it expands to the dark blue -- that's the annual ice in winter, and it contracts in summer.
The so-called permanent ice, five years old or older, you can see is almost like blood, spilling out of the body here.
In 25 years it's gone from this, to this.
This is a problem because the warming heats up the frozen ground around the Arctic Ocean, where there is a massive amount of frozen carbon which, when it thaws, is turned into methane by microbes.
Compared to the total amount of global warming pollution in the atmosphere, that amount could double if we cross this tipping point.
Already in some shallow lakes in Alaska, methane is actively bubbling up out of the water.
Professor Katey Walter from the University of Alaska went out with another team to another shallow lake last winter.
Video: Whoa! Al Gore: She's okay. The question is whether we will be.
And one reason is, this enormous heat sink heats up Greenland from the north.
This is an annual melting river.
But the volumes are much larger than ever.
This is the Kangerlussuaq River in southwest Greenland.
If you want to know how sea level rises from land-base ice melting this is where it reaches the sea.
These flows are increasing very rapidly.
At the other end of the planet, Antarctica the largest mass of ice on the planet.
Last month scientists reported the entire continent is now in negative ice balance.
And west Antarctica cropped up on top some under-sea islands, is particularly rapid in its melting.
That's equal to 20 feet of sea level, as is Greenland.
In the Himalayas, the third largest mass of ice: at the top you see new lakes, which a few years ago were glaciers.
40 percent of all the people in the world get half of their drinking water from that melting flow.
In the Andes, this glacier is the source of drinking water for this city.
The flows have increased.
But when they go away, so does much of the drinking water.
In California there has been a 40 percent decline in the Sierra snowpack.
This is hitting the reservoirs.
And the predictions, as you've read, are serious.
This drying around the world has lead to a dramatic increase in fires.
And the disasters around the world have been increasing at an absolutely extraordinary and unprecedented rate.
Four times as many in the last 30 years as in the previous 75.
This is a completely unsustainable pattern.
If you look at in the context of history you can see what this is doing.
In the last five years we've added 70 million tons of CO2 every 24 hours -- 25 million tons every day to the oceans.
Look carefully at the area of the eastern Pacific, from the Americas, extending westward, and on either side of the Indian subcontinent, where there is a radical depletion of oxygen in the oceans.
The biggest single cause of global warming, along with deforestation, which is 20 percent of it, is the burning of fossil fuels.
Oil is a problem, and coal is the most serious problem.
The United States is one of the two largest emitters, along with China.
And the proposal has been to build a lot more coal plants.
But we're beginning to see a sea change.
Here are the ones that have been cancelled in the last few years with some green alternatives proposed.
However there is a political battle in our country.
And the coal industries and the oil industries spent a quarter of a billion dollars in the last calendar year promoting clean coal, which is an oxymoron.
That image reminded me of something.
Around Christmas, in my home in Tennessee, a billion gallons of coal sludge was spilled.
You probably saw it on the news.
This, all over the country, is the second largest waste stream in America.
This happened around Christmas.
One of the coal industry's ads around Christmas was this one.
Video: Frosty the coal man is a jolly, happy soul.
He's abundant here in America, and he helps our economy grow.
Frosty the coal man is getting cleaner everyday.
He's affordable and adorable, and workers keep their pay.
Al Gore: This is the source of much of the coal in West Virginia.
The largest mountaintop miner is the head of Massey Coal.
Video: Don Blankenship: Let me be clear about it. Al Gore, Nancy Pelosi, Harry Reid, they don't know what they're talking about.
Al Gore: So the Alliance for Climate Protection has launched two campaigns.
This is one of them, part of one of them.
Video: Actor: At COALergy we view climate change as a very serious threat to our business.
That's why we've made it our primary goal to spend a large sum of money on an advertising effort to help bring out and complicate the truth about coal.
The fact is, coal isn't dirty.
We think it's clean -- smells good, too.
So don't worry about climate change.
Leave that up to us.
Video: Actor: Clean coal -- you've heard a lot about it.
So let's take a tour of this state-of-the-art clean coal facility.
Amazing! The machinery is kind of loud.
But that's the sound of clean coal technology.
And while burning coal is one of the leading causes of global warming, the remarkable clean coal technology you see here changes everything.
Take a good long look: this is today's clean coal technology.
Al Gore: Finally, the positive alternative meshes with our economic challenge and our national security challenge.
Video: Narrator: America is in crisis -- the economy, national security, the climate crisis.
The thread that links them all: our addiction to carbon based fuels, like dirty coal and foreign oil.
But now there is a bold new solution to get us out of this mess.
Repower America with 100 percent clean electricity within 10 years.
A plan to put America back to work, make us more secure, and help stop global warming.
Finally, a solution that's big enough to solve our problems.
Repower America. Find out more.
Al Gore: This is the last one.
Video: Narrator: It's about repowering America.
One of the fastest ways to cut our dependence on old dirty fuels that are killing our planet.
Man: Future's over here. Wind, sun, a new energy grid.
Man #2: New investments to create high-paying jobs.
Narrator: Repower America. It's time to get real.
Al Gore: There is an old African proverb that says, "If you want to go quickly, go alone.
If you want to go far, go together."
We need to go far, quickly.
Thank you very much.
Last year at TED I gave an introduction to the LHC.
And I promised to come back and give you an update on how that machine worked.
So this is it. And for those of you that weren't there, the LHC is the largest scientific experiment ever attempted -- 27 kilometers in circumference.
Its job is to recreate the conditions that were present less than a billionth of a second after the universe began, up to 600 million times a second.
It's nothing if not ambitious.
This is the machine below Geneva.
We take the pictures of those mini-Big Bangs inside detectors.
This is the one I work on. It's called the ATLAS detector -- 44 meters wide, 22 meters in diameter.
Spectacular picture here of ATLAS under construction so you can see the scale.
On the 10th of September last year we turned the machine on for the first time.
And this picture was taken by ATLAS.
It caused immense celebration in the control room.
It's a picture of the first beam particle going all the way around the LHC, colliding with a piece of the LHC deliberately, and showering particles into the detector.
In other words, when we saw that picture on September 10th we knew the machine worked, which is a great triumph.
I don't know whether this got the biggest cheer, or this, when someone went onto Google and saw the front page was like that.
It means we made cultural impact as well as scientific impact.
About a week later we had a problem with the machine, related actually to these bits of wire here -- these gold wires.
Those wires carry 13 thousand amps when the machine is working in full power.
Now the engineers amongst you will look at them and say, "No they don't. They're small wires."
They can do that because when they are very cold they are what's called superconducting wire.
So at minus 271 degrees, colder than the space between the stars, those wires can take that current.
In one of the joints between over 9,000 magnets in LHC, there was a manufacturing defect.
So the wire heated up slightly, and its 13,000 amps suddenly encountered electrical resistance.
This was the result.
Now that's more impressive when you consider those magnets weigh over 20 tons, and they moved about a foot.
So we damaged about 50 of the magnets.
We had to take them out, which we did.
We reconditioned them all, fixed them.
They're all on their way back underground now.
By the end of March the LHC will be intact again.
We will switch it on, and we expect to take data in June or July, and continue with our quest to find out what the building blocks of the universe are.
Now of course, in a way those accidents reignite the debate about the value of science and engineering at the edge. It's easy to refute.
I think that the fact that it's so difficult, the fact that we're overreaching, is the value of things like the LHC.
Thank you.
I want to start out by asking you to think back to when you were a kid, playing with blocks.
As you figured out how to reach out and grasp, pick them up and move them around, you were actually learning how to think and solve problems by understanding and manipulating spatial relationships.
Spatial reasoning is deeply connected to how we understand a lot of the world around us.
This question was so compelling that we decided to explore the answer, by building Siftables.
In a nutshell, a Siftable is an interactive computer the size of a cookie.
They're able to be moved around by hand, they can sense each other, they can sense their motion, and they have a screen and a wireless radio.
Most importantly, they're physical, so like the blocks, you can move them just by reaching out and grasping.
And Siftables are an example of a new ecosystem of tools for manipulating digital information.
And as these tools become more physical, more aware of their motion, aware of each other, and aware of the nuance of how we move them, we can start to explore some new and fun interaction styles.
So, I'm going to start with some simple examples.
This Siftable is configured to show video, and if I tilt it in one direction, it'll roll the video this way; if I tilt it the other way it rolls it backwards.
And these interactive portraits are aware of each other.
So if I put them next to each other, they get interested.
If they get surrounded, they notice that too, they might get a little flustered.
And they can also sense their motion and tilt.
One of the interesting implications on interaction, we started to realize, was that we could use everyday gestures on data, like pouring a color the way we might pour a liquid.
So in this case, we've got three Siftables configured to be paint buckets and I can use them to pour color into that central one, where they get mixed.
If we overshoot, we can pour a little bit back.
There are also some neat possibilities for education, like language, math and logic games where we want to give people the ability to try things quickly, and view the results immediately.
So here I'm -- This is a Fibonacci sequence that I'm making with a simple equation program.
Here we have a word game that's kind of like a mash-up between Scrabble and Boggle.
Basically, in every round you get a randomly assigned letter on each Siftable, and as you try to make words it checks against a dictionary.
Then, after about 30 seconds, it reshuffles, and you have a new set of letters and new possibilities to try.
Thank you.
So these are some kids that came on a field trip to the Media Lab, and I managed to get them to try it out, and shoot a video.
They really loved it.
And, one of the interesting things about this kind of application is that you don't have to give people many instructions.
All you have to say is, "Make words," and they know exactly what to do.
So here's another few people trying it out.
That's our youngest beta tester, down there on the right.
Turns out, all he wanted to do was to stack the Siftables up.
So to him, they were just blocks.
Now, this is an interactive cartoon application.
And we wanted to build a learning tool for language learners.
And this is Felix, actually.
And he can bring new characters into the scene, just by lifting the Siftables off the table that have that character shown on them.
Here, he's bringing the sun out.
Video: The sun is rising.
David Merrill: Now he's brought a tractor into the scene.
Video: The orange tractor.
Good job! Yeah!
DM: So by shaking the Siftables and putting them next to each other he can make the characters interact -- Video: Woof!
DM: inventing his own narrative.
Video: Hello!
DM: It's an open-ended story, and he gets to decide how it unfolds.
Video: Fly away, cat.
DM: So, the last example I have time to show you today is a music sequencing and live performance tool that we've built recently, in which Siftables act as sounds like lead, bass and drums.
Each of these has four different variations, you get to choose which one you want to use.
And you can inject these sounds into a sequence that you can assemble into the pattern that you want.
And you inject it by just bumping up the sound Siftable against a sequence Siftable.
There are effects that you can control live, like reverb and filter.
You attach it to a particular sound and then tilt to adjust it.
And then, overall effects like tempo and volume that apply to the entire sequence.
So let's have a look.
Video: DM: We'll start by putting a lead into two sequence Siftables, arrange them into a series, extend it, add a little more lead.
Now I put a bass line in.
Video: DM: Now I'll put some percussion in.
Video: DM: And now I'll attach the filter to the drums, so I can control the effect live.
Video: DM: I can speed up the whole sequence by tilting the tempo one way or the other.
Video: DM: And now I'll attach the filter to the bass for some more expression.
Video: DM: I can rearrange the sequence while it plays.
So I don't have to plan it out in advance, but I can improvise, making it longer or shorter as I go.
And now, finally, I can fade the whole sequence out using the volume Siftable, tilted to the left.
Thank you.
So, as you can see, my passion is for making new human-computer interfaces that are a better match to the ways our brains and bodies work.
And today, I had time to show you one point in this new design space, and a few of the possibilities that we're working to bring out of the laboratory.
So the thought I want to leave you with is that we're on the cusp of this new generation of tools for interacting with digital media that are going to bring information into our world on our terms.
Thank you very much.
I look forward to talking with all of you.
I am a writer.
Writing books is my profession but it's more than that, of course.
It is also my great lifelong love and fascination.
And I don't expect that that's ever going to change.
But, that said, something kind of peculiar has happened recently in my life and in my career, which has caused me to have to recalibrate my whole relationship with this work.
And the peculiar thing is that I recently wrote this book, this memoir called "Eat, Pray, Love" which, decidedly unlike any of my previous books, went out in the world for some reason, and became this big, mega-sensation, international bestseller thing.
The result of which is that everywhere I go now, people treat me like I'm doomed.
Seriously -- doomed, doomed!
Like, they come up to me now, all worried, and they say, "Aren't you afraid you're never going to be able to top that?
Aren't you afraid you're going to keep writing for your whole life and you're never again going to create a book that anybody in the world cares about at all, ever again?"
So that's reassuring, you know.
But it would be worse, except for that I happen to remember that over 20 years ago, when I was a teenager, when I first started telling people that I wanted to be a writer, I was met with this same sort of fear-based reaction.
And people would say, "Aren't you afraid you're never going to have any success?
Aren't you afraid the humiliation of rejection will kill you?
Aren't you afraid that you're going to work your whole life at this craft and nothing's ever going to come of it and you're going to die on a scrap heap of broken dreams with your mouth filled with bitter ash of failure?"
Like that, you know.
The answer -- the short answer to all those questions is, "Yes."
Yes, I'm afraid of all those things.
And I always have been.
And I'm afraid of many, many more things besides that people can't even guess at, like seaweed and other things that are scary.
But, when it comes to writing, the thing that I've been sort of thinking about lately, and wondering about lately, is why?
You know, is it rational?
Is it logical that anybody should be expected to be afraid of the work that they feel they were put on this Earth to do.
And what is it specifically about creative ventures that seems to make us really nervous about each other's mental health in a way that other careers kind of don't do, you know?
Like my dad, for example, was a chemical engineer and I don't recall once in his 40 years of chemical engineering anybody asking him if he was afraid to be a chemical engineer, you know?
"That chemical-engineering block, John, how's it going?"
It just didn't come up like that, you know?
But to be fair, chemical engineers as a group haven't really earned a reputation over the centuries for being alcoholic manic-depressives.
We writers, we kind of do have that reputation, and not just writers, but creative people across all genres, it seems, have this reputation for being enormously mentally unstable.
And all you have to do is look at the very grim death count in the 20th century alone, of really magnificent creative minds who died young and often at their own hands, you know?
And even the ones who didn't literally commit suicide seem to be really undone by their gifts, you know.
Norman Mailer, just before he died, last interview, he said, "Every one of my books has killed me a little more."
An extraordinary statement to make about your life's work.
But we don't even blink when we hear somebody say this, because we've heard that kind of stuff for so long and somehow we've completely internalized and accepted collectively this notion that creativity and suffering are somehow inherently linked and that artistry, in the end, will always ultimately lead to anguish.
And the question that I want to ask everybody here today is are you guys all cool with that idea?
Are you comfortable with that?
Because you look at it even from an inch away and, you know -- I'm not at all comfortable with that assumption.
I think it's odious.
And I also think it's dangerous, and I don't want to see it perpetuated into the next century.
I think it's better if we encourage our great creative minds to live.
And I definitely know that, in my case -- in my situation -- it would be very dangerous for me to start sort of leaking down that dark path of assumption, particularly given the circumstance that I'm in right now in my career.
Which is -- you know, like check it out, I'm pretty young, I'm only about 40 years old.
I still have maybe another four decades of work left in me.
And it's exceedingly likely that anything I write from this point forward is going to be judged by the world as the work that came after the freakish success of my last book, right?
I should just put it bluntly, because we're all sort of friends here now -- it's exceedingly likely that my greatest success is behind me.
So Jesus, what a thought!
That's the kind of thought that could lead a person to start drinking gin at nine o'clock in the morning, and I don't want to go there.
I would prefer to keep doing this work that I love.
And so, the question becomes, how?
And so, it seems to me, upon a lot of reflection, that the way that I have to work now, in order to continue writing, is that I have to create some sort of protective psychological construct, right?
I have to sort of find some way to have a safe distance between me, as I am writing, and my very natural anxiety about what the reaction to that writing is going to be, from now on.
And that search has led me to ancient Greece and ancient Rome.
So stay with me, because it does circle around and back.
But, ancient Greece and ancient Rome -- people did not happen to believe that creativity came from human beings back then, OK?
People believed that creativity was this divine attendant spirit that came to human beings from some distant and unknowable source, for distant and unknowable reasons.
The Greeks famously called these divine attendant spirits of creativity "daemons."
Socrates, famously, believed that he had a daemon who spoke wisdom to him from afar.
The Romans had the same idea, but they called that sort of disembodied creative spirit a genius.
Which is great, because the Romans did not actually think that a genius was a particularly clever individual.
They believed that a genius was this, sort of magical divine entity, who was believed to literally live in the walls of an artist's studio, kind of like Dobby the house elf, and who would come out and sort of invisibly assist the artist with their work and would shape the outcome of that work.
So brilliant -- there it is, right there, that distance that I'm talking about -- that psychological construct to protect you from the results of your work.
And everyone knew that this is how it functioned, right?
So the ancient artist was protected from certain things, like, for example, too much narcissism, right?
If your work was brilliant, you couldn't take all the credit for it, everybody knew that you had this disembodied genius who had helped you.
If your work bombed, not entirely your fault, you know?
Everyone knew your genius was kind of lame.
And this is how people thought about creativity in the West for a really long time.
And then the Renaissance came and everything changed, and we had this big idea, and the big idea was, let's put the individual human being at the center of the universe above all gods and mysteries, and there's no more room for mystical creatures who take dictation from the divine.
And it's the beginning of rational humanism, and people started to believe that creativity came completely from the self of the individual.
And for the first time in history, you start to hear people referring to this or that artist as being a genius, rather than having a genius.
And I got to tell you, I think that was a huge error.
You know, I think that allowing somebody, one mere person to believe that he or she is like, the vessel, you know, like the font and the essence and the source of all divine, creative, unknowable, eternal mystery is just a smidge too much responsibility to put on one fragile, human psyche.
It's like asking somebody to swallow the sun.
It just completely warps and distorts egos, and it creates all these unmanageable expectations about performance.
And I think the pressure of that has been killing off our artists for the last 500 years.
And, if this is true, and I think it is true, the question becomes, what now?
Can we do this differently?
Maybe go back to some more ancient understanding about the relationship between humans and the creative mystery.
Maybe not.
Maybe we can't just erase 500 years of rational humanistic thought in one 18 minute speech.
And there's probably people in this audience who would raise really legitimate scientific suspicions about the notion of, basically, fairies who follow people around rubbing fairy juice on their projects and stuff.
I'm not, probably, going to bring you all along with me on this.
But the question that I kind of want to pose is -- you know, why not?
Why not think about it this way?
Because it makes as much sense as anything else I have ever heard in terms of explaining the utter maddening capriciousness of the creative process.
A process which, as anybody who has ever tried to make something -- which is to say basically everyone here --- knows does not always behave rationally.
And, in fact, can sometimes feel downright paranormal.
And she said it was like a thunderous train of air.
And it would come barreling down at her over the landscape.
And she felt it coming, because it would shake the earth under her feet.
She knew that she had only one thing to do at that point, and that was to, in her words, "run like hell."
And she would run like hell to the house and she would be getting chased by this poem, and the whole deal was that she had to get to a piece of paper and a pencil fast enough so that when it thundered through her, she could collect it and grab it on the page.
And other times she wouldn't be fast enough, so she'd be running and running, and she wouldn't get to the house and the poem would barrel through her and she would miss it and she said it would continue on across the landscape, looking, as she put it "for another poet."
And then there were these times -- this is the piece I never forgot -- she said that there were moments where she would almost miss it, right?
So, she's running to the house and she's looking for the paper and the poem passes through her, and she grabs a pencil just as it's going through her, and then she said, it was like she would reach out with her other hand and she would catch it.
She would catch the poem by its tail, and she would pull it backwards into her body as she was transcribing on the page.
And in these instances, the poem would come up on the page perfect and intact but backwards, from the last word to the first.
So when I heard that I was like -- that's uncanny, that's exactly what my creative process is like.
That's not at all what my creative process is -- I'm not the pipeline!
I'm a mule, and the way that I have to work is I have to get up at the same time every day, and sweat and labor and barrel through it really awkwardly.
But even I, in my mulishness, even I have brushed up against that thing, at times.
And I would imagine that a lot of you have too.
You know, even I have had work or ideas come through me from a source that I honestly cannot identify.
And what is that thing?
And how are we to relate to it in a way that will not make us lose our minds, but, in fact, might actually keep us sane?
And for me, the best contemporary example that I have of how to do that is the musician Tom Waits, who I got to interview several years ago on a magazine assignment.
And we were talking about this, and you know, Tom, for most of his life, he was pretty much the embodiment of the tormented contemporary modern artist, trying to control and manage and dominate these sort of uncontrollable creative impulses that were totally internalized.
But then he got older, he got calmer, and one day he was driving down the freeway in Los Angeles, and this is when it all changed for him.
And he's speeding along, and all of a sudden he hears this little fragment of melody, that comes into his head as inspiration often comes, elusive and tantalizing, and he wants it, it's gorgeous, and he longs for it, but he has no way to get it.
He doesn't have a piece of paper, or a pencil, or a tape recorder.
So he starts to feel all of that old anxiety start to rise in him like, "I'm going to lose this thing, and I'll be be haunted by this song forever.
I'm not good enough, and I can't do it."
And instead of panicking, he just stopped.
He just stopped that whole mental process and he did something completely novel.
He just looked up at the sky, and he said, "Excuse me, can you not see that I'm driving?"
"Do I look like I can write down a song right now?
If you really want to exist, come back at a more opportune moment when I can take care of you.
Otherwise, go bother somebody else today.
Go bother Leonard Cohen."
And his whole work process changed after that.
Not the work, the work was still oftentimes as dark as ever.
But the process, and the heavy anxiety around it was released when he took the genie, the genius out of him where it was causing nothing but trouble, and released it back where it came from, and realized that this didn't have to be this internalized, tormented thing.
It could be this peculiar, wondrous, bizarre collaboration, kind of conversation between Tom and the strange, external thing that was not quite Tom.
When I heard that story, it started to shift a little bit the way that I worked too, and this idea already saved me once.
Not just bad, but the worst book ever written.
And I started to think I should just dump this project.
But then I remembered Tom talking to the open air and I tried it.
So I just lifted my face up from the manuscript and I directed my comments to an empty corner of the room.
And I said aloud, "Listen you, thing, you and I both know that if this book isn't brilliant that is not entirely my fault, right?
Because you can see that I am putting everything I have into this, I don't have any more than this.
If you want it to be better, you've got to show up and do your part of the deal.
But if you don't do that, you know what, the hell with it.
I'm going to keep writing anyway because that's my job.
And I would please like the record to reflect today that I showed up for my part of the job."
Because -- Because in the end it's like this, OK -- centuries ago in the deserts of North Africa, people used to gather for these moonlight dances of sacred dance and music that would go on for hours and hours, until dawn.
They were always magnificent, because the dancers were professionals and they were terrific, right?
But every once in a while, very rarely, something would happen, and one of these performers would actually become transcendent.
And I know you know what I'm talking about, because I know you've all seen, at some point in your life, a performance like this.
It was like time would stop, and the dancer would sort of step through some kind of portal and he wasn't doing anything different than he had ever done, 1,000 nights before, but everything would align.
And all of a sudden, he would no longer appear to be merely human.
He would be lit from within, and lit from below and all lit up on fire with divinity.
And when this happened, back then, people knew it for what it was, you know, they called it by its name.
They would put their hands together and they would start to chant, "Allah, Allah, Allah, God, God, God."
That's God, you know.
Curious historical footnote: when the Moors invaded southern Spain, they took this custom with them and the pronunciation changed over the centuries from "Allah, Allah, Allah," to "Ol, ol, ol," which you still hear in bullfights and in flamenco dances.
In Spain, when a performer has done something impossible and magic, "Allah, ol, ol, Allah, magnificent, bravo," incomprehensible, there it is -- a glimpse of God.
Which is great, because we need that.
But, the tricky bit comes the next morning, for the dancer himself, when he wakes up and discovers that it's Tuesday at 11 a.m., and he's no longer a glimpse of God.
He's just an aging mortal with really bad knees, and maybe he's never going to ascend to that height again.
And maybe nobody will ever chant God's name again as he spins, and what is he then to do with the rest of his life?
This is hard.
This is one of the most painful reconciliations to make in a creative life.
But maybe it doesn't have to be quite so full of anguish if you never happened to believe, in the first place, that the most extraordinary aspects of your being came from you.
But maybe if you just believed that they were on loan to you from some unimaginable source for some exquisite portion of your life to be passed along when you're finished, with somebody else.
And, you know, if we think about it this way, it starts to change everything.
This is how I've started to think, and this is certainly how I've been thinking in the last few months as I've been working on the book that will soon be published, as the dangerously, frighteningly over-anticipated follow up to my freakish success.
And what I have to sort of keep telling myself when I get really psyched out about that is don't be afraid.
Don't be daunted. Just do your job.
Continue to show up for your piece of it, whatever that might be.
If your job is to dance, do your dance.
If the divine, cockeyed genius assigned to your case decides to let some sort of wonderment be glimpsed, for just one moment through your efforts, then "Ol!"
And if not, do your dance anyhow.
And "Ol!" to you, nonetheless.
I believe this and I feel that we must teach it.
"Ol!" to you, nonetheless, just for having the sheer human love and stubbornness to keep showing up.
Thank you.
Thank you.
June Cohen: Ol!
You know, I've talked about some of these projects before -- about the human genome and what that might mean, and discovering new sets of genes.
We're actually starting at a new point: we've been digitizing biology, and now we're trying to go from that digital code into a new phase of biology with designing and synthesizing life.
So, we've always been trying to ask big questions.
"What is life?" is something that I think many biologists have been trying to understand at various levels.
We've tried various approaches, paring it down to minimal components.
We've been digitizing it now for almost 20 years; when we sequenced the human genome, it was going from the analog world of biology into the digital world of the computer.
Now we're trying to ask, "Can we regenerate life or can we create new life out of this digital universe?"
This is the map of a small organism, Mycoplasma genitalium, that has the smallest genome for a species that can self-replicate in the laboratory, and we've been trying to just see if we can come up with an even smaller genome.
We're able to knock out on the order of 100 genes out of the 500 or so that are here.
When we look at its metabolic map, it's relatively simple compared to ours -- trust me, this is simple -- but when we look at all the genes that we can knock out one at a time, it's very unlikely that this would yield a living cell.
So we decided the only way forward was to actually synthesize this chromosome so we could vary the components to ask some of these most fundamental questions.
And so we started down the road of: can we synthesize a chromosome?
Can chemistry permit making these really large molecules where we've never been before?
And if we do, can we boot up a chromosome?
A chromosome, by the way, is just a piece of inert chemical material.
So, our pace of digitizing life has been increasing at an exponential pace.
Our ability to write the genetic code has been moving pretty slowly but has been increasing, and our latest point would put it on, now, an exponential curve.
We started this over 15 years ago.
It took several stages, in fact, starting with a bioethical review before we did the first experiments.
But it turns out synthesizing DNA is very difficult.
There are tens of thousands of machines around the world that make small pieces of DNA -- 30 to 50 letters in length -- and it's a degenerate process, so the longer you make the piece, the more errors there are.
So we had to create a new method for putting these little pieces together and correct all the errors.
And this was our first attempt, starting with the digital information of the genome of phi X174.
It's a small virus that kills bacteria.
We designed the pieces, went through our error correction and had a DNA molecule of about 5,000 letters.
The exciting phase came when we took this piece of inert chemical and put it in the bacteria, and the bacteria started to read this genetic code, made the viral particles.
The viral particles then were released from the cells and came back and killed the E. coli.
I was talking to the oil industry recently and I said they clearly understood that model.
They laughed more than you guys are. And so, we think this is a situation where the software can actually build its own hardware in a biological system.
Design is critical, and if you're starting with digital information in the computer, that digital information has to be really accurate.
When we first sequenced this genome in 1995, the standard of accuracy was one error per 10,000 base pairs.
We actually found, on resequencing it, 30 errors; had we used that original sequence, it never would have been able to be booted up.
Part of the design is designing pieces that are 50 letters long that have to overlap with all the other 50-letter pieces to build smaller subunits we have to design so they can go together.
We design unique elements into this.
You may have read that we put watermarks in.
Think of this: we have a four-letter genetic code -- A, C, G and T.
Triplets of those letters code for roughly 20 amino acids, such that there's a single letter designation for each of the amino acids.
So we can use the genetic code to write out words, sentences, thoughts.
Initially, all we did was autograph it.
Some people were disappointed there was not poetry.
We designed these pieces so we can just chew back with enzymes; there are enzymes that repair them and put them together.
And we started making pieces, starting with pieces that were 5,000 to 7,000 letters, put those together to make 24,000-letter pieces, then put sets of those going up to 72,000.
At each stage, we grew up these pieces in abundance so we could sequence them because we're trying to create a process that's extremely robust that you can see in a minute.
We're trying to get to the point of automation.
So, this looks like a basketball playoff.
When we get into these really large pieces over 100,000 base pairs, they won't any longer grow readily in E. coli -- it exhausts all the modern tools of molecular biology -- and so we turned to other mechanisms.
We knew there's a mechanism called homologous recombination that biology uses to repair DNA that can put pieces together.
Here's an example of it: there's an organism called Deinococcus radiodurans that can take three millions rads of radiation.
You can see in the top panel, its chromosome just gets blown apart.
Twelve to 24 hours later, it put it back together exactly as it was before.
We have thousands of organisms that can do this.
These organisms can be totally desiccated; they can live in a vacuum.
I am absolutely certain that life can exist in outer space, move around, find a new aqueous environment.
In fact, NASA has shown a lot of this is out there.
Here's an actual micrograph of the molecule we built using these processes, actually just using yeast mechanisms with the right design of the pieces we put them in; yeast puts them together automatically.
This is not an electron micrograph; this is just a regular photomicrograph.
It's such a large molecule we can see it with a light microscope.
These are pictures over about a six-second period.
So, this is the publication we had just a short while ago.
This is over 580,000 letters of genetic code; it's the largest molecule ever made by humans of a defined structure.
It's over 300 million molecular weight.
If we printed it out at a 10 font with no spacing, it takes 142 pages just to print this genetic code.
Well, how do we boot up a chromosome? How do we activate this?
Obviously, with a virus it's pretty simple; it's much more complicated dealing with bacteria.
It's also simpler when you go into eukaryotes like ourselves: you can just pop out the nucleus and pop in another one, and that's what you've all heard about with cloning.
With bacteria and Archaea, the chromosome is integrated into the cell, but we recently showed that we can do a complete transplant of a chromosome from one cell to another and activate it.
The new chromosome went into the cell.
In fact, we thought this might be as far as it went, but we tried to design the process a little bit further.
This is a major mechanism of evolution right here.
We find all kinds of species that have taken up a second chromosome or a third one from somewhere, adding thousands of new traits in a second to that species.
So, people who think of evolution as just one gene changing at a time have missed much of biology.
There are enzymes called restriction enzymes that actually digest DNA.
The chromosome that was in the cell doesn't have one; the chromosome we put in does.
It got expressed and it recognized the other chromosome as foreign material, chewed it up, and so we ended up just with a cell with the new chromosome.
It turned blue because of the genes we put in it.
And with a very short period of time, all the characteristics of one species were lost and it converted totally into the new species based on the new software that we put in the cell.
All the proteins changed, the membranes changed; when we read the genetic code, it's exactly what we had transferred in.
So, this may sound like genomic alchemy, but we can, by moving the software of DNA around, change things quite dramatically.
Now I've argued, this is not genesis; this is building on three and a half billion years of evolution.
And I've argued that we're about to perhaps create a new version of the Cambrian explosion, where there's massive new speciation based on this digital design.
Why do this?
I think this is pretty obvious in terms of some of the needs.
We're about to go from six and a half to nine billion people over the next 40 years.
To put it in context for myself: I was born in 1946.
There are now three people on the planet for every one of us that existed in 1946; within 40 years, there'll be four.
We have trouble feeding, providing fresh, clean water, medicines, fuel for the six and a half billion.
It's going to be a stretch to do it for nine.
We use over five billion tons of coal, 30 billion-plus barrels of oil -- that's a hundred million barrels a day.
When we try to think of biological processes or any process to replace that, it's going to be a huge challenge.
Then of course, there's all that CO2 from this material that ends up in the atmosphere.
We now, from our discovery around the world, have a database with about 20 million genes, and I like to think of these as the design components of the future.
The electronics industry only had a dozen or so components, and look at the diversity that came out of that.
We're limited here primarily by a biological reality and our imagination.
We now have techniques, because of these rapid methods of synthesis, to do what we're calling combinatorial genomics.
We have the ability now to build a large robot that can make a million chromosomes a day.
When you think of processing these 20 million different genes or trying to optimize processes to produce octane or to produce pharmaceuticals, new vaccines, we can just with a small team, do more molecular biology than the last 20 years of all science.
And it's just standard selection: we can select for viability, chemical or fuel production, vaccine production, etc.
This is a screen snapshot of some true design software that we're working on to actually be able to sit down and design species in the computer.
You know, we don't know necessarily what it'll look like: we know exactly what their genetic code looks like.
We're focusing on now fourth-generation fuels.
You've seen recently, corn to ethanol is just a bad experiment.
We have second- and third-generation fuels that will be coming out relatively soon that are sugar, to much higher-value fuels like octane or different types of butanol.
But the only way we think that biology can have a major impact without further increasing the cost of food and limiting its availability is if we start with CO2 as its feedstock, and so we're working with designing cells to go down this road.
And we think we'll have the first fourth-generation fuels in about 18 months.
Sunlight and CO2 is one method ...
but in our discovery around the world, we have all kinds of other methods.
This is an organism we described in 1996.
It lives in the deep ocean, about a mile and a half deep, almost at boiling-water temperatures.
It takes CO2 to methane using molecular hydrogen as its energy source.
We're looking to see if we can take captured CO2, which can easily be piped to sites, convert that CO2 back into fuel to drive this process.
So, in a short period of time, we think that we might be able to increase what the basic question is of "What is life?"
We truly, you know, have modest goals of replacing the whole petrol-chemical industry -- Yeah. If you can't do that at TED, where can you? -- become a major source of energy ...
But also, we're now working on using these same tools to come up with instant sets of vaccines.
You've seen this year with flu; we're always a year behind and a dollar short when it comes to the right vaccine.
I think that can be changed by building combinatorial vaccines in advance.
Here's what the future may begin to look like with changing, now, the evolutionary tree, speeding up evolution with synthetic bacteria, Archaea and, eventually, eukaryotes.
We're a ways away from improving people: our goal is just to make sure that we have a chance to survive long enough to maybe do that. Thank you very much.
We're looking at many, many gigabytes of digital photos here and kind of seamlessly and continuously zooming in, panning through it, rearranging it in any way we want.
And it doesn't matter how much information we're looking at, how big these collections are or how big the images are.
Most of them are ordinary digital camera photos, but this one, for example, is a scan from the Library of Congress, and it's in the 300 megapixel range.
It doesn't make any difference because the only thing that ought to limit the performance of a system like this one is the number of pixels on your screen at any given moment.
It's also very flexible architecture.
This is an entire book, so this is an example of non-image data.
This is "Bleak House" by Dickens. Every column is a chapter.
To prove to you that it's really text, and not an image, we can do something like so, to really show that this is a real representation of the text; it's not a picture.
Maybe this is an artificial way to read an e-book.
I wouldn't recommend it.
This is a more realistic case, an issue of The Guardian.
Every large image is the beginning of a section.
And this really gives you the joy and the good experience of reading the real paper version of a magazine or a newspaper, which is an inherently multi-scale kind of medium.
We've done something with the corner of this particular issue of The Guardian.
We've made up a fake ad that's very high resolution -- much higher than in an ordinary ad -- and we've embedded extra content.
If you want to see the features of this car, you can see it here.
Or other models, or even technical specifications.
And this really gets at some of these ideas about really doing away with those limits on screen real estate.
We hope that this means no more pop-ups and other rubbish like that -- shouldn't be necessary.
Of course, mapping is one of those obvious applications for a technology like this.
And this one I really won't spend any time on, except to say that we have things to contribute to this field as well.
But those are all the roads in the U.S.
superimposed on top of a NASA geospatial image.
So let's pull up, now, something else.
This is actually live on the Web now; you can go check it out.
This is a project called Photosynth, which marries two different technologies.
One of them is Seadragon and the other is some very beautiful computer-vision research done by Noah Snavely, a graduate student at the University of Washington, co-advised by Steve Seitz at U.W.
and Rick Szeliski at Microsoft Research. A very nice collaboration.
And so this is live on the Web. It's powered by Seadragon.
You can see that when we do these sorts of views, where we can dive through images and have this kind of multi-resolution experience.
But the spatial arrangement of the images here is actually meaningful.
The computer vision algorithms have registered these images together so that they correspond to the real space in which these shots -- all taken near Grassi Lakes in the Canadian Rockies -- all these shots were taken.
So you see elements here of stabilized slide-show or panoramic imaging, and these things have all been related spatially.
I'm not sure if I have time to show you any other environments.
Some are much more spatial.
We had to worry about the lawyers and so on.
This is a reconstruction of Notre Dame Cathedral that was done entirely computationally from images scraped from Flickr.
You just type Notre Dame into Flickr, and you get some pictures of guys in T-shirts, and of the campus and so on.
And each of these orange cones represents an image that was discovered to belong to this model.
And so these are all Flickr images, and they've all been related spatially in this way.
We can just navigate in this very simple way.
(Applause ends) You know, I never thought that I'd end up working at Microsoft.
It's very gratifying to have this kind of reception here.
I guess you can see this is lots of different types of cameras: it's everything from cell-phone cameras to professional SLRs, quite a large number of them, stitched together in this environment.
If I can find some of the sort of weird ones -- So many of them are occluded by faces, and so on.
Somewhere in here there is actually a series of photographs -- here we go.
This is actually a poster of Notre Dame that registered correctly.
We can dive in from the poster to a physical view of this environment.
What the point here really is is that we can do things with the social environment.
This is now taking data from everybody -- from the entire collective memory, visually, of what the Earth looks like -- and link all of that together.
Those photos become linked, and they make something emergent that's greater than the sum of the parts.
You have a model that emerges of the entire Earth.
Think of this as the long tail to Stephen Lawler's Virtual Earth work.
And this is something that grows in complexity as people use it, and whose benefits become greater to the users as they use it.
Their own photos are getting tagged with meta-data that somebody else entered.
And of course, a by-product of all of that is immensely rich virtual models of every interesting part of the Earth, collected not just from overhead flights and from satellite images and so on, but from the collective memory.
Thank you so much.
Chris Anderson: Do I understand this right? What your software is going to allow, is that at some point, really within the next few years, all the pictures that are shared by anyone across the world are going to link together?
BAA: Yes. What this is really doing is discovering, creating hyperlinks, if you will, between images.
It's doing that based on the content inside the images.
And that gets really exciting when you think about the richness of the semantic information a lot of images have.
Like when you do a web search for images, you type in phrases, and the text on the web page is carrying a lot of information about what that picture is of.
What if that picture links to all of your pictures?
The amount of semantic interconnection and richness that comes out of that is really huge.
It's a classic network effect.
CA: Truly incredible. Congratulations.
And of course, we all share the same adaptive imperatives.
We're all born. We all bring our children into the world.
We go through initiation rites.
We have to deal with the inexorable separation of death, so it shouldn't surprise us that we all sing, we all dance, we all have art.
But what's interesting is the unique cadence of the song, the rhythm of the dance in every culture.
All of these peoples teach us that there are other ways of being, other ways of thinking, other ways of orienting yourself in the Earth.
And this is an idea, if you think about it, can only fill you with hope.
Now, together the myriad cultures of the world make up a web of spiritual life and cultural life that envelops the planet, and is as important to the well-being of the planet as indeed is the biological web of life that you know as a biosphere.
And you might think of this cultural web of life as being an ethnosphere, and you might define the ethnosphere as being the sum total of all thoughts and dreams, myths, ideas, inspirations, intuitions brought into being by the human imagination since the dawn of consciousness.
The ethnosphere is humanity's great legacy.
It's the symbol of all that we are and all that we can be as an astonishingly inquisitive species.
And just as the biosphere has been severely eroded, so too is the ethnosphere -- and, if anything, at a far greater rate.
And the great indicator of that, of course, is language loss.
When each of you in this room were born, there were 6,000 languages spoken on the planet.
Now, a language is not just a body of vocabulary or a set of grammatical rules.
A language is a flash of the human spirit.
It's a vehicle through which the soul of each particular culture comes into the material world.
Every language is an old-growth forest of the mind, a watershed, a thought, an ecosystem of spiritual possibilities.
And of those 6,000 languages, as we sit here today in Monterey, fully half are no longer being whispered into the ears of children.
They're no longer being taught to babies, which means, effectively, unless something changes, they're already dead.
What could be more lonely than to be enveloped in silence, to be the last of your people to speak your language, to have no way to pass on the wisdom of the ancestors or anticipate the promise of the children?
And yet, that dreadful fate is indeed the plight of somebody somewhere on Earth roughly every two weeks, because every two weeks, some elder dies and carries with him into the grave the last syllables of an ancient tongue.
And I know there's some of you who say, "Well, wouldn't it be better, wouldn't the world be a better place if we all just spoke one language?" And I say, "Great, let's make that language Yoruba. Let's make it Cantonese.
Let's make it Kogi."
And you'll suddenly discover what it would be like to be unable to speak your own language.
And so, what I'd like to do with you today is sort of take you on a journey through the ethnosphere, a brief journey through the ethnosphere, to try to begin to give you a sense of what in fact is being lost.
Now, there are many of us who sort of forget that when I say "different ways of being," I really do mean different ways of being.
Take, for example, this child of a Barasana in the Northwest Amazon, the people of the anaconda who believe that mythologically they came up the milk river from the east in the belly of sacred snakes.
Now, this is a people who cognitively do not distinguish the color blue from the color green because the canopy of the heavens is equated to the canopy of the forest upon which the people depend.
They have a curious language and marriage rule which is called "linguistic exogamy:" you must marry someone who speaks a different language.
And this is all rooted in the mythological past, yet the curious thing is in these long houses, where there are six or seven languages spoken because of intermarriage, you never hear anyone practicing a language.
They simply listen and then begin to speak.
Or, one of the most fascinating tribes I ever lived with, the Waorani of northeastern Ecuador, an astonishing people first contacted peacefully in 1958.
In 1957, five missionaries attempted contact and made a critical mistake.
They dropped from the air 8 x 10 glossy photographs of themselves in what we would say to be friendly gestures, forgetting that these people of the rainforest had never seen anything two-dimensional in their lives.
They picked up these photographs from the forest floor, tried to look behind the face to find the form or the figure, found nothing, and concluded that these were calling cards from the devil, so they speared the five missionaries to death.
But the Waorani didn't just spear outsiders.
They speared each other.
54 percent of their mortality was due to them spearing each other.
Their hunters could smell animal urine at 40 paces and tell you what species left it behind.
In the early '80s, I had a really astonishing assignment when I was asked by my professor at Harvard if I was interested in going down to Haiti, infiltrating the secret societies which were the foundation of Duvalier's strength and Tonton Macoutes, and securing the poison used to make zombies.
In order to make sense out of sensation, of course, I had to understand something about this remarkable faith of Vodoun. And Voodoo is not a black magic cult.
On the contrary, it's a complex metaphysical worldview.
It's interesting.
If I asked you to name the great religions of the world, what would you say?
Christianity, Islam, Buddhism, Judaism, whatever.
There's always one continent left out, the assumption being that sub-Saharan Africa had no religious beliefs. Well, of course, they did and Voodoo is simply the distillation of these very profound religious ideas that came over during the tragic Diaspora of the slavery era.
But, what makes Voodoo so interesting is that it's this living relationship between the living and the dead.
So, the living give birth to the spirits.
The spirits can be invoked from beneath the Great Water, responding to the rhythm of the dance to momentarily displace the soul of the living, so that for that brief shining moment, the acolyte becomes the god.
That's why the Voodooists like to say that "You white people go to church and speak about God.
We dance in the temple and become God."
And because you are possessed, you are taken by the spirit -- how can you be harmed?
So you see these astonishing demonstrations: Voodoo acolytes in a state of trance handling burning embers with impunity, a rather astonishing demonstration of the ability of the mind to affect the body that bears it when catalyzed in the state of extreme excitation.
Now, of all the peoples that I've ever been with, the most extraordinary are the Kogi of the Sierra Nevada de Santa Marta in northern Colombia.
Descendants of the ancient Tairona civilization which once carpeted the Caribbean coastal plain of Colombia, in the wake of the conquest, these people retreated into an isolated volcanic massif that soars above the Caribbean coastal plain.
In a bloodstained continent, these people alone were never conquered by the Spanish.
To this day, they remain ruled by a ritual priesthood but the training for the priesthood is rather extraordinary.
And for this entire time, they are inculturated into the values of their society, values that maintain the proposition that their prayers and their prayers alone maintain the cosmic -- or we might say the ecological -- balance.
It is that beautiful. It is yours to protect."
They call themselves the "elder brothers" and they say we, who are the younger brothers, are the ones responsible for destroying the world.
Now, this level of intuition becomes very important.
Whenever we think of indigenous people and landscape, we either invoke Rousseau and the old canard of the "noble savage," which is an idea racist in its simplicity, or alternatively, we invoke Thoreau and say these people are closer to the Earth than we are.
Well, indigenous people are neither sentimental nor weakened by nostalgia.
Now, what does that mean?
Whether it's the abode of a spirit or a pile of ore is irrelevant.
What's interesting is the metaphor that defines the relationship between the individual and the natural world.
I was raised in the forests of British Columbia to believe those forests existed to be cut.
That made me a different human being than my friends amongst the Kwagiulth who believe that those forests were the abode of Huxwhukw and the Crooked Beak of Heaven and the cannibal spirits that dwelled at the north end of the world, spirits they would have to engage during their Hamatsa initiation.
Now, if you begin to look at the idea that these cultures could create different realities, you could begin to understand some of their extraordinary discoveries. Take this plant here.
It's a photograph I took in the Northwest Amazon just last April.
This is ayahuasca, which many of you have heard about, the most powerful psychoactive preparation of the shaman's repertoire.
This plant had in it some very powerful tryptamines, very close to brain serotonin, dimethyltryptamine, 5-methoxydimethyltryptamine.
If you've ever seen the Yanomami blowing that snuff up their noses, that substance they make from a different set of species also contains methoxydimethyltryptamine.
To have that powder blown up your nose is rather like being shot out of a rifle barrel lined with baroque paintings and landing on a sea of electricity. It doesn't create the distortion of reality; it creates the dissolution of reality.
They can only be taken orally if taken in conjunction with some other chemical that denatures the MAO.
Now, the fascinating things are that the beta-carbolines found within that liana are MAO inhibitors of the precise sort necessary to potentiate the tryptamine. So you ask yourself a question.
How, in a flora of 80,000 species of vascular plants, do these people find these two morphologically unrelated plants that when combined in this way, created a kind of biochemical version of the whole being greater than the sum of the parts?
Well, we use that great euphemism, "trial and error," which is exposed to be meaningless.
But you ask the Indians, and they say, "The plants talk to us."
Well, what does that mean?
This tribe, the Cofan, has 17 varieties of ayahuasca, all of which they distinguish a great distance in the forest, all of which are referable to our eye as one species.
And then you ask them how they establish their taxonomy and they say, "I thought you knew something about plants.
I mean, don't you know anything?" And I said, "No."
Well, it turns out you take each of the 17 varieties in the night of a full moon, and it sings to you in a different key.
All cultures through all time have constantly been engaged in a dance with new possibilities of life.
And the problem is not technology itself.
The Sioux Indians did not stop being Sioux when they gave up the bow and arrow any more than an American stopped being an American when he gave up the horse and buggy.
It's not change or technology that threatens the integrity of the ethnosphere. It is power, the crude face of domination.
Or if we go into the mountains of Tibet, where I'm doing a lot of research recently, you'll see it's a crude face of political domination.
You know, genocide, the physical extinction of a people is universally condemned, but ethnocide, the destruction of people's way of life, is not only not condemned, it's universally, in many quarters, celebrated as part of a development strategy.
And you cannot understand the pain of Tibet until you move through it at the ground level.
This young man's father had been ascribed to the Panchen Lama.
That meant he was instantly killed at the time of the Chinese invasion.
His uncle fled with His Holiness in the Diaspora that took the people to Nepal.
His mother was incarcerated for the crime of being wealthy.
He was smuggled into the jail at the age of two to hide beneath her skirt tails because she couldn't bear to be without him.
The sister who had done that brave deed was put into an education camp.
One day she inadvertently stepped on an armband of Mao, and for that transgression, she was given seven years of hard labor.
The pain of Tibet can be impossible to bear, but the redemptive spirit of the people is something to behold.
And in the end, then, it really comes down to a choice: do we want to live in a monochromatic world of monotony or do we want to embrace a polychromatic world of diversity?
And it's humbling to remember that our species has, perhaps, been around for [150,000] years.
The Neolithic Revolution -- which gave us agriculture, at which time we succumbed to the cult of the seed; the poetry of the shaman was displaced by the prose of the priesthood; we created hierarchy specialization surplus -- is only 10,000 years ago.
The modern industrial world as we know it is barely 300 years old.
Now, that shallow history doesn't suggest to me that we have all the answers for all of the challenges that will confront us in the ensuing millennia.
When these myriad cultures of the world are asked the meaning of being human, they respond with 10,000 different voices.
And it's within that song that we will all rediscover the possibility of being what we are: a fully conscious species, fully aware of ensuring that all peoples and all gardens find a way to flourish. And there are great moments of optimism.
This is a photograph I took at the northern tip of Baffin Island when I went narwhal hunting with some Inuit people, and this man, Olayuk, told me a marvelous story of his grandfather.
The Canadian government has not always been kind to the Inuit people, and during the 1950s, to establish our sovereignty, we forced them into settlements.
This old man's grandfather refused to go.
The family, fearful for his life, took away all of his weapons, all of his tools.
Now, you must understand that the Inuit did not fear the cold; they took advantage of it.
The runners of their sleds were originally made of fish wrapped in caribou hide.
So, this man's grandfather was not intimidated by the Arctic night or the blizzard that was blowing.
He simply slipped outside, pulled down his sealskin trousers and defecated into his hand. And as the feces began to freeze, he shaped it into the form of a blade.
He put a spray of saliva on the edge of the shit knife and as it finally froze solid, he butchered a dog with it.
He skinned the dog and improvised a harness, took the ribcage of the dog and improvised a sled, harnessed up an adjacent dog, and disappeared over the ice floes, shit knife in belt.
Talk about getting by with nothing. And this, in many ways -- -- is a symbol of the resilience of the Inuit people and of all indigenous people around the world.
The Canadian government in April of 1999 gave back to total control of the Inuit an area of land larger than California and Texas put together.
It's our new homeland. It's called Nunavut.
It's an independent territory. They control all mineral resources.
An amazing example of how a nation-state can seek restitution with its people.
And finally, in the end, I think it's pretty obvious at least to all of all us who've traveled in these remote reaches of the planet, to realize that they're not remote at all.
They're homelands of somebody.
They represent branches of the human imagination that go back to the dawn of time. And for all of us, the dreams of these children, like the dreams of our own children, become part of the naked geography of hope.
So, what we're trying to do at the National Geographic, finally, is, we believe that politicians will never accomplish anything.
We think that polemics -- -- we think that polemics are not persuasive, but we think that storytelling can change the world, and so we are probably the best storytelling institution in the world. We get 35 million hits on our website every month.
156 nations carry our television channel.
Our magazines are read by millions.
Thank you very much.
I'm going to talk to you about some stuff that's in this book of mine that I hope will resonate with other things you've already heard, and I'll try to make some connections myself, in case you missed them.
But I want to start with what I call the "official dogma."
The official dogma of what?
The official dogma of all Western industrial societies.
And the official dogma runs like this: if we are interested in maximizing the welfare of our citizens, the way to do that is to maximize individual freedom.
The reason for this is both that freedom is in and of itself good, valuable, worthwhile, essential to being human.
And because if people have freedom, then each of us can act on our own to do the things that will maximize our welfare, and no one has to decide on our behalf.
The way to maximize freedom is to maximize choice.
The more choice people have, the more freedom they have, and the more freedom they have, the more welfare they have.
This, I think, is so deeply embedded in the water supply that it wouldn't occur to anyone to question it.
And it's also deeply embedded in our lives.
I'll give you some examples of what modern progress has made possible for us.
This is my supermarket. Not such a big one.
I want to say just a word about salad dressing.
175 salad dressings in my supermarket, if you don't count the 10 extra-virgin olive oils and 12 balsamic vinegars you could buy to make a very large number of your own salad dressings, in the off-chance that none of the 175 the store has on offer suit you.
So this is what the supermarket is like.
And then you go to the consumer electronics store to set up a stereo system -- speakers, CD player, tape player, tuner, amplifier -- and in this one single consumer electronics store, there are that many stereo systems.
We can construct six-and-a-half-million different stereo systems out of the components that are on offer in one store.
You've got to admit that's a lot of choice.
In other domains -- the world of communications.
There was a time, when I was a boy, when you could get any kind of telephone service you wanted, as long as it came from Ma Bell.
You rented your phone. You didn't buy it.
One consequence of that, by the way, is that the phone never broke.
And those days are gone.
We now have an almost unlimited variety of phones, especially in the world of cell phones.
These are cell phones of the future.
My favorite is the middle one -- the MP3 player, nose hair trimmer, and crme brle torch.
And if by some chance you haven't seen that in your store yet, you can rest assured that one day soon, you will.
And what this does is it leads people to walk into their stores asking this question.
And do you know what the answer to this question now is?
The answer is "no."
It is not possible to buy a cell phone that doesn't do too much.
So, in other aspects of life that are much more significant than buying things, the same explosion of choice is true.
Health care. It is no longer the case in the United States that you go to the doctor, and the doctor tells you what to do.
Instead, you go to the doctor, and the doctor tells you, "Well, we could do A, or we could do B.
A has these benefits, and these risks.
B has these benefits, and these risks. What do you want to do?"
And you say, "Doc, what should I do?"
And the doc says, "A has these benefits and risks, and B has these benefits and risks.
What do you want to do?"
And you say, "If you were me, Doc, what would you do?"
And the doc says, "But I'm not you."
There's enormous marketing of prescription drugs to people like you and me, which, if you think about it, makes no sense at all, since we can't buy them.
Why do they market to us if we can't buy them?
The answer is that they expect us to call our doctors the next morning and ask for our prescriptions to be changed.
Something as dramatic as our identity has now become a matter of choice, as this slide is meant to indicate.
We don't inherit an identity; we get to invent it.
And we get to re-invent ourselves as often as we like.
And that means that every day, when you wake up in the morning, you have to decide what kind of person you want to be.
With respect to marriage and family, there was a time when the default assumption that almost everyone had is that you got married as soon as you could, and then you started having kids as soon as you could.
The only real choice was who, not when, and not what you did after.
Nowadays, everything is very much up for grabs.
I teach wonderfully intelligent students, and I assign 20 percent less work than I used to.
And it's not because they're less smart, and it's not because they're less diligent.
It's because they are preoccupied, asking themselves, "Should I get married or not? Should I get married now?
Should I get married later? Should I have kids first, or a career first?"
All of these are consuming questions.
And they're going to answer these questions, whether or not it means not doing all the work I assign and not getting a good grade in my courses.
And indeed they should. These are important questions to answer.
Work -- we are blessed, as Carl was pointing out, with the technology that enables us to work every minute of every day from any place on the planet -- except the Randolph Hotel.
There is one corner, by the way, that I'm not going to tell anybody about, where the WiFi actually works.
I'm not telling you about it because I want to use it.
So what this means, this incredible freedom of choice we have with respect to work, is that we have to make a decision, again and again and again, about whether we should or shouldn't be working.
We can go to watch our kid play soccer, and we have our cell phone on one hip, and our Blackberry on our other hip, and our laptop, presumably, on our laps.
And even if they're all shut off, every minute that we're watching our kid mutilate a soccer game, we are also asking ourselves, "Should I answer this cell phone call?
Should I respond to this email? Should I draft this letter?"
And even if the answer to the question is "no," it's certainly going to make the experience of your kid's soccer game very different than it would've been.
So everywhere we look, big things and small things, material things and lifestyle things, life is a matter of choice.
And the world we used to live in looked like this. [Well, actually, they are written in stone.] That is to say, there were some choices, but not everything was a matter of choice.
And the world we now live in looks like this.
And the question is, is this good news, or bad news?
And the answer is, "yes."
We all know what's good about it, so I'm going to talk about what's bad about it.
All of this choice has two effects, two negative effects on people.
One effect, paradoxically, is that it produces paralysis, rather than liberation.
With so many options to choose from, people find it very difficult to choose at all.
I'll give you one very dramatic example of this: a study that was done of investments in voluntary retirement plans.
A colleague of mine got access to investment records from Vanguard, the gigantic mutual-fund company of about a million employees and about 2,000 different workplaces.
And what she found is that for every 10 mutual funds the employer offered, rate of participation went down two percent.
You offer 50 funds -- 10 percent fewer employees participate than if you only offer five. Why?
Because with 50 funds to choose from, it's so damn hard to decide which fund to choose, that you'll just put it off until tomorrow.
And then tomorrow, and tomorrow, and tomorrow, and of course tomorrow never comes.
Understand that not only does this mean that people are going to have to eat dog food when they retire because they don't have enough money put away, it also means that making the decision is so hard that they pass up significant matching money from the employer.
By not participating, they are passing up as much as 5,000 dollars a year from the employer, who would happily match their contribution.
So paralysis is a consequence of having too many choices.
And I think it makes the world look like this.
You really want to get the decision right if it's for all eternity, right?
You don't want to pick the wrong mutual fund, or the wrong salad dressing.
So that's one effect. The second effect is that even if we manage to overcome the paralysis and make a choice, we end up less satisfied with the result of the choice than we would be if we had fewer options to choose from.
And there are several reasons for this.
The more options there are, the easier it is to regret anything at all that is disappointing about the option that you chose.
Second, what economists call "opportunity costs."
Dan Gilbert made a big point this morning of talking about how much the way in which we value things depends on what we compare them to.
Well, when there are lots of alternatives to consider, it is easy to imagine the attractive features of alternatives that you reject that make you less satisfied with the alternative that you've chosen.
Here's an example. [I can't stop thinking about those other available parking spaces on W 85th street] Sorry if you're not New Yorkers.
Here's what you're supposed to be thinking.
Here's this couple on the Hamptons.
Very expensive real estate.
Gorgeous beach. Beautiful day. They have it all to themselves.
What could be better?
"Well, damn it," this guy is thinking, "It's August. Everybody in my Manhattan neighborhood is away.
I could be parking right in front of my building."
And he spends two weeks nagged by the idea that he is missing the opportunity, day after day, to have a great parking space.
Opportunity costs subtract from the satisfaction we get out of what we choose, even when what we choose is terrific.
And the more options there are to consider, the more attractive features of these options are going to be reflected by us as opportunity costs.
Here's another example.
Now this cartoon makes a lot of points.
It makes points about living in the moment as well, and probably about doing things slowly.
But one point it makes is that whenever you're choosing one thing, you're choosing not to do other things that may have lots of attractive features, and it's going to make what you're doing less attractive.
Third: escalation of expectations.
This hit me when I went to replace my jeans.
I wear jeans almost all the time.
There was a time when jeans came in one flavor, and you bought them, and they fit like crap, they were incredibly uncomfortable, if you wore them and washed them enough times, they started to feel OK.
I went to replace my jeans after years of wearing these old ones, and I said, "I want a pair of jeans. Here's my size."
And the shopkeeper said, "Do you want slim fit, easy fit, relaxed fit?
You want button fly or zipper fly? You want stonewashed or acid-washed?
Do you want them distressed?
You want boot cut, tapered, blah blah." On and on he went.
My jaw dropped. And after I recovered, I said, "I want the kind that used to be the only kind."
He had no idea what that was, so I spent an hour trying on all these damn jeans, and I walked out of the store -- truth! -- with the best-fitting jeans I had ever had.
But -- I felt worse.
Why? I wrote a whole book to try to explain this to myself.
The reason I felt worse is that, with all of these options available, my expectations about how good a pair of jeans should be went up.
I had very low, no particular expectations when they only came in one flavor.
When they came in 100 flavors, damn it, one of them should've been perfect.
And what I got was good, but it wasn't perfect.
And so I compared what I got to what I expected, and what I got was disappointing in comparison to what I expected.
Adding options to people's lives can't help but increase the expectations people have about how good those options will be.
And what that's going to produce is less satisfaction with results, even when they're good results.
Nobody in the world of marketing knows this.
Because if they did, you wouldn't all know what this was about.
The truth is more like this.
[Everything was better back when everything was worse] The reason that everything was better back when everything was worse is that when everything was worse, it was actually possible for people to have experiences that were a pleasant surprise.
Nowadays, the world we live in -- we affluent, industrialized citizens, with perfection the expectation -- the best you can ever hope for is that stuff is as good as you expect it to be.
You will never be pleasantly surprised because your expectations, my expectations, have gone through the roof.
The secret to happiness -- this is what you all came for -- the secret to happiness is low expectations.
I want to say -- just a little autobiographical moment -- that I actually am married to a wife, and she's really quite wonderful.
I couldn't have done better.
But settling isn't always such a bad thing.
Finally -- One consequence of buying a bad-fitting pair of jeans when there is only one kind to buy is that when you are dissatisfied, and you ask why, who's responsible, the answer is clear: the world is responsible.
What could you do?
When there are hundreds of different styles of jeans available, and you buy one that is disappointing, and you ask why, who's responsible?
It is equally clear that the answer to the question is "you."
You could have done better.
With a hundred different kinds of jeans on display, there is no excuse for failure.
And so when people make decisions, and even though the results of the decisions are good, they feel disappointed about them; they blame themselves.
Clinical depression has exploded in the industrial world in the last generation.
I believe a significant -- not the only, but a significant -- contributor to this explosion of depression, and also suicide, is that people have experiences that are disappointing because their standards are so high, and then when they have to explain these experiences to themselves, they think they're at fault.
And so the net result is that we do better in general, objectively, and we feel worse.
So let me remind you.
This is the official dogma, the one that we all take to be true, and it's all false. It is not true.
There's no question that some choice is better than none, but it doesn't follow from that that more choice is better than some choice.
There's some magical amount. I don't know what it is.
I'm pretty confident that we have long since passed the point where options improve our welfare.
Now, as a policy matter -- I'm almost done -- as a policy matter, the thing to think about is this: what enables all of this choice in industrial societies is material affluence.
There are lots of places in the world, and we have heard about several of them, where their problem is not that they have too much choice.
Their problem is that they have too little.
So the stuff I'm talking about is the peculiar problem of modern, affluent, Western societies.
And what is so frustrating and infuriating is this: Steve Levitt talked to you yesterday about how these expensive and difficult-to-install child seats don't help.
What I'm telling you is that these expensive, complicated choices -- it's not simply that they don't help.
They actually hurt.
They actually make us worse off.
If some of what enables people in our societies to make all of the choices we make were shifted to societies in which people have too few options, not only would those people's lives be improved, but ours would be improved also, which is what economists call a "Pareto-improving move."
Income redistribution will make everyone better off -- not just poor people -- because of how all this excess choice plagues us.
So to conclude. [You can be anything you want to be -- no limits] You're supposed to read this cartoon, and, being a sophisticated person, say, "Ah! What does this fish know?
You know, nothing is possible in this fishbowl."
Impoverished imagination, a myopic view of the world -- and that's the way I read it at first.
The more I thought about it, however, the more I came to the view that this fish knows something.
Because the truth of the matter is that if you shatter the fishbowl so that everything is possible, you don't have freedom. You have paralysis.
If you shatter this fishbowl so that everything is possible, you decrease satisfaction.
You increase paralysis, and you decrease satisfaction.
Everybody needs a fishbowl.
This one is almost certainly too limited -- perhaps even for the fish, certainly for us.
But the absence of some metaphorical fishbowl is a recipe for misery, and, I suspect, disaster.
Thank you very much.

View File

@@ -0,0 +1,851 @@
El ao pasado proyect estas dos diapositivas para demostrar que la capa de hielo rtico, que durante los ltimos tres millones de aos ha sido del tamao de los 48 estados, se ha reducido en un 40 por ciento.
Pero esto minimiza la seriedad de este problema concreto porque no muestra el grosor del hielo.
La capa de hielo rtico es, en cierta forma, el corazn palpitante del sistema climtico global.
Se expande en invierno y se contrae en verano.
La siguiente diapositiva que mostrar ser una aceleracin de lo que ha sucedido en los ltimos 25 aos.
El hielo permanente est marcado en rojo.
Como ven, se expande hasta el azul oscuro. Ese es el hielo anual en invierno. Y se contrae en verano.
El as llamado hielo permanente, de cinco aos o ms, pueden ver que es casi como la sangre, derramndose del cuerpo.
En 25 aos ha pasado de esto, a esto.
Este es un problema porque el calentamiento afecta al suelo helado en torno al ocano rtico donde hay una cantidad enorme de carbono helado que, al derretirse, es convertido en metano por los microbios.
Comparado con el total de contaminacin del calentamiento global en la atmsfera, esa cantidad podra duplicarse si cruzamos este punto inflexin.
Ahora mismo en algunos lagos de Alaska el metano est emergiendo a borbotones del agua.
El profesor Katey Walter de la Universidad de Alaska fue el invierno pasado con otro equipo a otro lago poco profundo.
Video: Impresionante! Al Gore: Ella est bien. La pregunta es si lo estaremos nosotros.
Y una razn es, que este enorme disipador de calor calienta Groenlandia desde el norte.
ste es un ro de deshielo anual.
Pero los volmenes son ms grandes que nunca.
ste es el ro Kangerlussuaq en el suroeste de Groenlandia.
Si quieren saber cmo se eleva el nivel del mar por el derretimiento del hielo terrestre esto es donde llega al mar.
Estas corrientes se incrementan rpidamente.
Al otro extremo del planeta, la Antrtida la masa de hielo ms grande del planeta.
El mes pasado los cientficos informaron de que el continente est ahora en balance negativo de hielo.
Y la Antrtida occidental que se apoya sobre islas submarinas, es especialmente rpida en su deshielo.
Eso equivale a seis metros de nivel marino, como Groenlandia.
En los Himalayas, la tercera masa de hielo ms grande, desde la cima se ven nuevos lagos, que hace unos aos eran glaciares.
El 40 por ciento de la gente en el mundo obtiene la mitad del agua potable de esa corriente de deshielo.
En los Andes, este glaciar es la fuente de agua potable para esta ciudad.
Las corrientes han aumentado.
Pero cuando se vayan, tambin lo har gran parte del agua.
En California la nieve en Sierra ha disminuido en un 40 por ciento.
Esto afecta a los embalses.
Y las predicciones, como han ledo, son preocupantes.
Esta sequa en el mundo ha llevado a un aumento drstico de los incendios.
Y los desastres en todo el mundo se han incrementado a un ritmo totalmente inslito y sin precedentes.
Se ha multiplicado por cuatro en los ltimos 30 aos respecto a los 75 aos anteriores.
ste es un patrn completamente insostenible.
Si observan dentro del contexto de la historia pueden comprender lo que esto est provocando.
En los ltimos cinco aos hemos aadido 70 millones de toneladas de CO2 cada 24 horas... 25 millones de toneladas cada da a los ocanos.
Observen con atencin el rea del Pacfico oriental, desde las Amricas, hacia el oeste, y en cada lado del subcontinente Indio donde hay un agotamiento drstico de oxgeno en el ocano.
La mayor causa del calentamiento global, junto a la deforestacin, que supone el 20 por ciento, es la quema de combustibles fsiles.
El petrleo es un problema, y el carbn es el problema ms grave.
Los Estados Unidos es uno de los dos mayores emisores, junto con China.
Y la propuesta ha sido construir ms plantas de carbn.
Pero empezamos a ver un cambio radical.
Aqu estn las que se han suspendido en los ltimos aos con algunas alternativas verdes sugeridas.
Sin embargo hay una batalla poltica en nuestro pas.
Y las industrias del carbn y del petrleo se gastaron 250 millones de dlares el ltimo ao promoviendo el carbn limpio, lo que constituye un oxmoron.
Esa imagen me record algo.
Por Navidades, en mi hogar en Tennessee, se derramaron 3.800 millones de litros de lodo de carbn.
Seguramente lo vieron en las noticias.
ste es, de todo el pas, el segundo flujo de residuos ms grande de EE. UU.
Sucedi por Navidades.
Uno de los anuncios de la industria del carbn en Navidades fue ste.
Video: Frosty, el hombre de carbn, es un alma alegre y jovial.
Abunda aqu en EEUU, y contribuye a que la economa crezca..
Cada da Frosty el hombre de carbn se est haciendo ms limpio.
Es bueno, bonito y barato y los trabajadores mantienen su salario.
Al Gore: sta es la fuente de mucho del carbn en Virginia Occidental.
El minero de la mayor explotacin a cielo abierto dirige Massey Coal.
Video: Don Blankenship: Djenme aclarar algo, Al Gore, Nancy Pelosi, Harry Reid, no saben de qu estn hablando.
Al Gore: As que la Alianza por la Proteccin del Clima ha lanzado dos campaas.
Esta es una de ellas, parte de una de ellas.
Video: Actor: En COALergy vemos el cambio climtico como una seria amenaza a nuestros negocios.
Por eso nos hemos marcado como primer objetivo gastar mucho dinero en un esfuerzo publicitario para contribuir a sacar a la luz y enmaraar la verdad sobre el carbn.
La verdad es que, el carbn no es sucio.
Creemos que es limpio... huele bien, tambin.
As que no se preocupen por el cambio climtico.
Djennos esto a nosotros.
Video: Actor: Carbn limpio, ya han escuchado mucho hablar de l.
As que recorramos una instalacin de carbn limpio moderna.
Asombroso! La maquinaria hace como ruido.
Pero es el sonido de la tecnologa de carbn limpio.
Y mientras que quemar carbn es una de las causas del calentamiento global, la excepcional tecnologa limpia de carbn que ven aqu lo cambia todo.
Miren bien, es la tecnologa de carbn limpio de hoy.
Al Gore: Finalmente, la alternativa positiva se cruza con nuestro desafo econmico y nuestro desafo de seguridad nacional.
Video: Narrador: EEUU est en crisis, la economa, la seguridad nacional, la crisis climtica.
Y la amenaza que lo une todo, nuestra adiccin a combustibles basados en el carbn, el carbn sucio y el petrleo extranjero.
Pero ahora hay una solucin para salir de este desastre.
Dotar a EE.UU. de un nuevo modelo energtico de electricidad 100% limpia, en los siguientes 10 aos.
Un plan para poner a EEUU a trabajar, hacernos ms seguros, y detener el calentamiento global.
Finalmente, una solucin suficiente para resolver nuestros problemas.
Un nuevo modelo energtico para EE.UU. Descubran ms.
Al Gore: ste es el ltimo.
Video: Narrador: Se trata de dotar de un nuevo modelo energtico a EE.UU.
Una de las maneras ms rpidas de cortar nuestra dependencia de los combustibles sucios que matan el planeta.
Hombre: El futuro est aqu. Viento, sol, una nueva red de energa.
Hombre 2: Nuevas inversiones que crearn empleos.
Narrador: Un nuevo modelo energtico para EE.UU. Es hora de ser realistas.
Al Gore: Hay un viejo refrn africano que dice, "Si quieren ir rpido, vayan solos.
Si quieren llegar lejos, vayan juntos".
Tenemos que llegar lejos, rpido.
Muchas gracias.
El ao pasado en TED di una introduccin al Gran Colisionador de Hadrones.
Y promet volver y ponerlos al tanto de cmo funcionaba la mquina.
Y aqu estoy. Para quienes no estuvieron all, el LHC es el experimento cientfico ms grande que se haya intentado jams, y tiene 27 kilmetros de circunferencia.
Su labor es recrear las condiciones que existieron menos de una mil millonsima de segundo despus del inicio del universo, hasta 600 millones de veces por segundo.
Es algo muy ambicioso.
Esta es la mquina, bajo Ginebra.
Tomamos fotos de esos mini big bangs dentro de los detectores.
Yo trabajo en ste, el cual es llamado el detector ATLAS. 44 m. de ancho, 22 m. de dimetro.
Esta es una foto espectacular de ATLAS en construccin, para que vean la escala.
El pasado 10 de septiembre encendimos esta mquina por primera vez.
Y esta imagen fue tomada por ATLAS.
Caus una gran celebracin en la sala de control.
Es una foto del primer haz de partculas dando la vuelta completa en el LHC, chocando de forma deliberada contra una seccin del LHC, y lanzando partculas al detector.
Es decir, cuando vimos esa foto el 10 de septiembre supimos que la mquina funcionaba, lo que es un gran triunfo.
No s si la ovacin ms grande fue sta o fue cuando alguien entr a Google y vio as a la pgina principal.
Significa que tuvimos impacto, tanto cientfica como culturalmente.
Alrededor de una semana despus tuvimos un problema, tuvo que ver con estos tramos de cable, estos cables de oro.
Esos cables transmiten 13 mil amperes cuando la mquina est a toda potencia.
Los que son ingenieros los mirarn y dirn: "No lo hacen. Son cables pequeos."
Pueden hacerlo porque cuando estn muy fros son cables superconductores.
Entonces, a menos 271 grados, ms fros que en el espacio interestelar, esos cables pueden transmitir esa corriente.
En una de las uniones que hay entre los ms de 9000 magnetos hubo un defecto de fabricacin.
As que el cable se calent ligeramente. Y sus 13 mil amperes repentinamente encontraron resistencia elctrica.
Y este fue el resultado.
Eso es an ms impresionante si consideran que esos magnetos pesan ms de 20 toneladas y se movieron alrededor de 30 cm.
Se daaron alrededor de 50 magnetos.
Tenamos que quitarlos y lo hicimos.
Los reacondicionamos, los arreglamos.
Ahora van de regreso para all abajo.
A finales de marzo el LHC estar como nuevo otra vez.
Lo encenderemos y esperamos recibir datos en junio o julio. Y seguiremos con nuestra bsqueda de cules son los componentes fundamentales del universo.
Por supuesto, de cierta forma esos accidentes reavivaron el debate sobre el valor de la ciencia y la ingeniera de vanguardia. Es fcil refutarlo.
Creo que el hecho de que sea tan difcil, de estar excediendo nuestro alcance, es lo que hace tan valiosas a cosas como el LHC.
Gracias.
Quiero empezar pidindoles que recuerden cuando eran nios, jugando con bloques.
Mientras aprendan como alcanzarlos y tomarlos, levantarlos y moverlos, En realidad estaban aprendiendo cmo pensar y solucionar problemas a travs del entendimiento y manipulacin de relaciones espaciales.
El razonamiento espacial est profundamente conectado a cmo entendemos mucho del mundo a nuestro alrededor.
Esta pregunta fue tan irresistible que decidimos explorar la respuesta, construyendo los Siftables.
En breve, un Siftable es una computadora interactiva del tamao de una galleta.
Se pueden mover con las manos, se pueden detectar entre s, pueden detectar su movimiento, tienen una pantalla y una conexin inalmbrica.
Ms importante, son fsicos, as que como los bloques, los puedes mover simplemente alcanzndolos y tomndolos.
Y los Siftables son un ejemplo de un nuevo ecosistema de herramientas para manipular informacin digital.
Y mientras estas herramientas se vuelven ms fsicas, ms conscientes de su movimiento, conscientes uno de otro, y conscientes de las sutilezas de cmo los movemos, nosotros empezamos a explorar nuevos y divertidos estilos de interaccin.
As que, voy a empezar con algunos ejemplos simples.
Este Siftable est configurado para mostrar video, y si lo inclino en una direccin, rodar el video de esta manera, y si lo inclino en la otra, lo rodar en reversa.
Y estos retratos interactivos estn conscientes uno del otro.
As que si los pongo juntos, se interesan.
Si quedan rodeados, tambin se dan cuenta, se pueden poner algo nerviosos.
Tambin pueden detectar su movimiento e inclinacin.
Una de las implicaciones interesantes de sta interaccin, nos empezamos a dar cuenta, fue que podamos usar gestos comunes en datos, como vaciar color en la manera en que vaciamos un lquido.
As que en este caso, tenemos tres Siftables configurados como botes de pintura y los puedo usar para vaciar color a este central, donde se mezclan.
Si nos excedemos, podemos regresar un poco.
Tambin hay algunas buenas posibilidades para la educacin, como los idiomas, las matemticas y los juegos lgicos, donde queremos darle a la gente la habilidad de probar cosas rpidamente, y ver los resultados de inmediato.
As que aqu yo... Esta es una secuencia de Fibonacci que estoy haciendo con un simple programa de ecuaciones.
Aqu tenemos un juego de palabras que es algo as como una mezcla de Scrabble y Boggle.
Bsicamente, en cada ronda recibes una letra asignada al azar en cada Siftable, y mientras pruebas formar palabras las revisa contra un diccionario.
Entonces, despus de cerca de 30 segundos se reinicia, y tienes un nuevo conjunto de letras y nuevas posibilidades a intentar.
Gracias.
Entonces, estos son unos nios que nos visitaron en Medina Lab, y arregl que los nios los probaran y tomamos un video.
Realmente les encant.
Y una de las cosas interesantes acerca de este tipo de aplicacin es que no tienes que darle a la gente muchas instrucciones.
Todo lo que tienes que decir es: "Formen Palabras", y saben exactamente qu hacer.
As que aqu hay otros personas probndolos.
Este es nuestro probador beta ms joven, abajo a la derecha.
Resulta que todo lo que quera hacer era apilar los Siftables.
As que para l, slo eran bloques.
Ahora, esta aplicacin es una caricatura interactiva
y queramos construir una herramienta de aprendizaje para el idioma.
Y este es Flix, de hecho.
Y puede traer nuevos personajes a la escena, simplemente con levantar de la mesa los Siftables que muestran al personaje.
Aqu, est poniendo al sol.
Video: El sol se eleva.
David Merrill: Ahora ha trado un tractor a escena.
Video: El tractor naranja
Buen trabajo! S!
Al agitar los Siftables y colocndolos juntos puede hacer a los personajes interactuar. Video: Guau!
DM: inventando su propia narrativa.
Video: Hola!
DM: Es una historia con final abierto, y l decide como se desarrolla
Video: Vuela, gato.
DM: Entonces, el ltimo ejemplo que tengo tiempo de mostrarles hoy es una herramienta para secuenciar msica y actuacin en vivo que construimos recientemente, en la cual los Siftables actan como sonidos tales como instrumento lder, bajo y tambores.
Cada uno de stos tiene cuatro diferentes variaciones, y t eliges cul quieres usar.
Y puedes inyectar estos sonidos a una secuencia la cual puedes ensamblar en el patrn que quieras.
Y lo inyectas simplemente al golpear un Siftable de sonido contra un Siftable de secuencia.
Estos son efectos que puedes controlar en vivo, como reverberacin y filtros.
Lo conectas a un sonido en particular y lo inclinas para ajustarlo.
Y despus, efectos globales como tempo y volumen que se aplican a la secuencia entera.
As que veamos.
Video: DM: Empezaremos poniendo un instrumento lder en dos Siftables de secuencia, los organizamos en una serie, la extendemos, y agregamos sonido.
Ahora, introduzco el bajo.
Video: DM: Ahora pondr algo de percusin
Video: DM: Y ahora conecto el filtro a los tambores, para poder controlar el efecto en vivo.
Video: DM: Puedo acelerar la secuencia completa al inclinar el tempo en una u otra direccin.
Video: DM: Y ahora conectar el filtro al bajo para conseguir ms expresin.
Video: DM: Y puedo reacomodar la secuencia mientras toca.
As que no tengo que planearla previamente, pero puedo improvisar, acortndola alargndola en la marcha.
Y ahora, finalmente, puedo atenuar toda la secuencia usando el Siftable de volumen, inclinndolo a la izquierda.
Gracias.
As que, como pueden ver, mi pasin es realizar nuevas interfaces entre humanos y computadoras que se acoplen mejor a la forma en que nuestros cerebros y cuerpos funcionan.
Y hoy, tuve tiempo de mostrarles un punto en este nuevo espacio de diseo, y algunas de las posibilidades en las que estamos trabajando para sacar del laboratorio.
As que los quiero dejar con un pensamiento: estamos en la cspide de esta nueva generacin de herramientas para interactuar con medios digitales, las cuales van a traer informacin a nuestro mundo bajo nuestros trminos.
Muchas gracias.
Espero hablar con todos ustedes.
Soy escritora.
Escribir libros es mi profesin; pero es ms que eso, por supuesto.
Es tambin el gran amor y pasin de mi vida.
Y espero que eso no cambie nunca.
Pero, dicho esto, recientemente ha ocurrido algo poco peculiar en mi vida y mi carrera, lo que ha supuesto redefinir completamente mi relacin con este trabajo.
Y lo peculiar es que recientemente escrib este libro, esta novela llamada "Come, Reza, Ama" que, decididamente a diferencia de mis libros anteriores, sali al mundo por alguna razn, y se convirti en un enorme, mega-sensacional e internacionalmente xito literario.
El resultado de esto es que a donde quiera que vaya, la gente me trata como si estuviera desahuciada.
De verdad, desahuciada, desahuciada!
Por ejemplo, se acercan a m, muy preocupados y dicen, "No tienes miedo de que no puedas nunca superar este xito?
No tienes miedo de que vayas a continuar escribiendo toda tu vida y nunca ms vayas a crear un libro que le importe a alguien en el mundo, nunca jams?"
As que eso es tranquilizante, saben.
Pero sera peor, excepto que recuerdo que hace ms de 20 aos, cuando empec a decir -- cuando era una adolescente -- que quera ser una escritora, me top con este mismo tipo de reaccin basada en miedo.
Y la gente preguntaba, "No tienes miedo de que nunca vayas a tener xito?
No tienes miedo de que la humillacin del rechazo te mate?
No tienes miedo de trabajar toda tu vida en este arte y de que nada vaya a salir de eso y de que morirs sobre una pila de sueos rotos con tu boca llena de la amarga ceniza del fracaso?"
Algo as, saben.
La respuesta - la respuesta corta a todas sas preguntas es, "S."
S, tengo miedo de todas esas cosas.
Y siempre lo he tenido.
Y tengo miedo de muchas, muchas otras cosas que la gente ni siquiera puede adivinar. Como las algas, y otras cosas que dan miedo.
Pero, cuando se trata de escribir, en lo que he estado pensando ltimamente, y que me he estado preguntando, es por qu?
Ya saben, es racional?
Es acaso lgico que se espere que uno tenga miedo del trabajo para el que siente que fue puesto en la Tierra?
Ya saben, y que es eso que especficamente tienen las carreras creativos que aparentemente nos pone realmente nerviosos sobre la salud mental de los dems de una manera que otras carreras no lo hacen, saben?
Como mi pap, por ejemplo, que era un ingeniero qumico y no recuerdo ni una vez en sus 40 aos de ingeniera qumica que alguien le preguntara si tena miedo de ser un ingeniero qumico, saben?
No suceda -- el ingeniero qumico ese, John, como va?
Simplemente no pasaba, saben?
Pero para ser justos, los ingenieros qumicos como grupo no se han ganado una reputacin a lo largo de los siglos de ser alcohlicos manaco-depresivos.
Nosotros los escritores, tenemos esa reputacin, y no solo escritores, sino la gente creativa de todo tipo, parece tener esta reputacin de ser enormemente inestable mentalmente.
Y todo lo que tienes que hacer es ver esta sombra lista de muertes slo en el siglo XX, de mentes creativas magnficas que murieron jvenes y a menudo por su propia mano, saben?
E incluso los que no se suicidaron parecen destruidos por sus dones, saben?
Norman Mailer, justo antes de morir, su ltima entrevista, dijo "Cada uno de mis libros me ha matado un poco ms."
Una declaracin extraordinaria acerca del trabajo de tu vida, saben?
Pero ni siquiera pestaeamos cuando omos a alguien decir esto porque hemos odo cosas como sta por tanto tiempo y de alguna manera hemos interiorizado y aceptado colectivamente esta idea de que la creatividad y el sufrimiento estn inherentemente ligados y que el arte, al final, siempre llevar a la angustia.
Y la pregunta que quiero hacerles a todos hoy es estn todos ustedes a gusto con esa idea?
Se sienten cmodos con ella --
porque la ven aunque sea a slo una pulgada de distancia y, saben -- yo no me siento cmoda con esa suposicin.
Creo que es odiosa.
Y tambin creo que es peligrosa, y no quiero verla perpetuada en el prximo siglo.
Creo que es mejor si alentamos a nuestras grandes mentes creativas a vivir.
Y definitivamente creo que, en mi caso -- en mi situacin -- sera muy peligroso para m empezar a fugarme por ese camino oscuro de suposicin, particularmente dada la circunstancia en la que estoy justo en este punto de mi carrera.
La cual es -- ustedes saben, bueno, soy bastante joven, slo tengo alrededor de 40 aos.
Tal vez tengo todava otras cuatro dcadas de trabajo en m.
Y es extremadamente posible que cualquier cosa que escriba de ahora en adelante sea juzgada por el mundo como el trabajo que vino despus del extrao xito de mi libro pasado, verdad?
Debera decirlo sin rodeos, porque somos todos como amigos aqu -- es extremadamente probable que mi mayor xito ya haya pasado.
Oh, Jess, qu idea!
Saben que es el tipo de pensamiento que gua a una persona a beber ginebra a las nueve de la maana y no quiero hacer eso.
Preferira continuar haciendo este trabajo que amo.
As que, la pregunta se vuelve cmo?
Y a m me parece, despus de mucha reflexin, que la forma en la que tengo que trabajar ahora, para seguir escribiendo, es que tengo que crear algn tipo de constructo psicolgico de proteccin, verdad?
Tengo que encontrar algn modo de tener una distancia segura entre m, mientras escribo, y mi ansiedad natural sobre lo que ser la reaccin a lo que escriba, de ahora en adelante.
Y esa bsqueda me ha llevado a la antigua Grecia y a la antigua Roma.
As que mantnganse conmigo, porque esto da la vuelta completa.
Pero, en la Grecia y Roma antiguas -- la gente no crea que la creatividad vena de los seres humanos, OK?
La gente crea que la creatividad era este espritu asistente divino que vena a los humanos de una fuente distante y desconocida, por razones distantes y desconocidas.
Los griegos llamaron a estos espritus divinos asistentes de la creatividad, "daimones."
Scrates, popularmente se crea que tena un daimon que le hablaba con sabidura desde lejos.
Los Romanos tenan la misma idea, pero llamaban a este espritu creativo incorpreo un genio.
Lo que es genial, porque los Romanos no crean que un genio era un individuo particularmente inteligente.
Ellos crean que un genio era este tipo de entidad mgica y divina, que se crea, viva, literalmente, en las paredes del estudio de un artista, algo as como Dobby el elfo domestico, y que sala y asista invisiblemente al artista con su trabajo y daba forma al resultado de ese trabajo.
Tan brillante -- ah est, justo ah esa distancia de la que estoy hablando -- ese constructo psicolgico para protegerse de los resultados de tu trabajo.
Y todos saban que as es como funcionaba, verdad?
As el artista antiguo estaba protegido de ciertas cosas, como, por ejemplo, demasiado narcisismo, verdad?
Si tu trabajo era brillante no te podas atribuir todo el mrito por l, todos saban que tuviste este genio incorpreo que te haba ayudado.
Si tu trabajo fracasaba, no era totalmente tu culpa, saben?
Todos saban que tu genio era algo dbil.
Y eso es lo que la gente pensaba sobre la creatividad en Occidente por mucho tiempo.
Y entonces lleg el Renacimiento y todo cambi, y tuvimos esta gran idea, y la gran idea fue vamos a poner al ser humano individual en el centro del universo sobre todos los dioses y misterios, y no hay ms espacio para criaturas msticas que toman dictado de lo divino.
Y es el principio del humanismo racional, y la gente empez a creer que la creatividad vena completamente del individuo mismo.
Y por primera vez en la historia, empiezas a escuchar a gente referirse a este o aquel artista como si fuera un genio en vez de tener un genio.
Y debo decirles, creo que eso fue un gran error.
Saben, creo que permitir a alguien, una simple persona creer que l o ella es como, el contenedor, como la fuente, la esencia y el origen de todo misterio divino, creativo, desconocido es quiz demasiada responsabilidad para una frgil psique humana.
Es como pedirle a alguien que se trague el sol.
Deforma y distorsiona egos, y crea todas estas expectativas inmanejables sobre el rendimiento.
Y creo que la presin de eso ha estado matando a nuestros artistas los ltimos 500 aos.
Y, si esto es verdad, y yo creo que es verdad, la pregunta se vuelve, ahora qu?
Podemos hacer esto de una manera diferente?
Tal vez regresar a una comprensin ms antigua sobre la relacin entre humanos y el misterio creativo.
Tal vez no.
Tal vez no podemos simplemente borrar 500 aos de pensamiento humanstico racional en un discurso de 18 minutos.
Y probablemente hay gente en esta audiencia que puede tener legtimas sospechas cientficas sobre la nocin de hadas, bsicamente, que siguen a la gente frotando zumo de hada en sus proyectos y cosas as.
No voy a conseguir que todos estn de acuerdo conmigo.
Pero la pregunta que quiero presentar es -- Por qu no?
Por qu no pensar de esta manera?
Porque tiene tanto sentido como cualquier otra cosa que yo haya escuchado en trminos de explicar la enloquecedora arbitrariedad absoluta del proceso creativo.
Un proceso que, como cualquiera que alguna vez haya intentado hacer algo conoce -- lo que es decir, bsicamente todos los presentes -- no siempre se comporta racionalmente.
Y, de hecho, a veces puede sentirse definitivamente paranormal.
Y dijo que era como un atronador tren de aire.
Y vendra hacia ella descontroladamente sobre el paisaje.
Y lo senta venir, porque haca que la tierra temblara bajo sus pies.
Ella saba que solo tena una cosa que hacer en ese momento, y era, en sus palabras, "correr como una endemoniada."
Y corra como una endemoniada a la casa y era perseguida por este poema, y lo que deba hacer era que tena que conseguir un pedazo de papel y un lpiz lo suficientemente rpido para que cuando tronara a travs de ella, lo pudiera recoger y atraparlo en la pgina.
Y a veces no era lo suficientemente rpida, as que ella estara corriendo y corriendo, y no llegara a la casa y el poema la atropellara y ella lo perda y ella dijo que seguira avanzando sobre el paisaje, buscando, como ella dijo, "a otro poeta."
Y a veces existan estas ocasiones -- esta es la parte que nunca olvid -- dijo que existan momentos en los que ella casi lo perda, verdad?
As que, est corriendo a la casa y buscando el papel y el poema la pasaba de largo, y ella agarraba el lpiz justo mientras pasaba por ella, y entonces ella dijo, era como si lo hubiera alcanzado con su otra mano y lo hubiera atrapado.
Atrapaba el poema por la cola, y lo tiraba hacia atrs dentro de su cuerpo mientras lo transcriba en la pgina.
Y en estas ocasiones, el poema apareca en la pgina perfecto e intacto pero al revs, de la ltima palabra a la primera.
As que cuando lo escuch pens -- que extrao, as es exactamente mi proceso creativo.
Eso no es todo mi proceso creativo -- No soy la tubera!
Soy una mula, y la manera que tengo de trabajar es que me tengo que levantar a la misma hora todos los das, y sudar y trabajar y pasar por todo eso torpemente.
Pero an yo, en mi mulismo, an yo me he rozado contra esa cosa, a veces.
Y me imagino que muchos de ustedes tambin.
Saben, incluso he tenido trabajo o ideas que vienen a m desde una fuente que honestamente no puedo identificar .
Y qu es esa cosa?
Y cmo podemos relacionarnos con ella sin que nos haga perder el juicio, pero, de hecho, nos mantenga cuerdos?
Y para m, el mejor ejemplo contemporneo que tengo de cmo hacerlo es el msico Tom Waits, a quien entrevist hace algunos aos para una revista.
Y estbamos hablando acerca de esto, y ya saben, Tom, por la mayor parte de su vida ha sido el ejemplo del atormentado artista moderno contemporneo, intentando controlar y manejar y dominar estos impulsos creativos incontrolables que estn totalmente interiorizados.
Pero entonces se volvi ms viejo, ms tranquilo, y un da estaba conduciendo en la autopista en Los ngeles me dijo, y fue entonces cuando todo cambi para l.
Est conduciendo, y de repente escucha este pequeo fragmento de meloda, que viene a su cabeza como llega la inspiracin a menudo, evasiva y sugerente, y la quiere, ustedes saben, es hermosa, y la aora, pero no tiene manera de conseguirla.
No tiene un pedazo de papel, no tiene un lpiz, no tiene una grabadora.
As que empieza a sentir esa vieja ansiedad crecer en l as como, "Voy a perder esta cosa, y entonces esta cancin me va a atormentar para siempre.
No soy lo suficientemente bueno, no puedo hacerlo."
Y en vez de caer en el pnico, se detuvo.
Detuvo el proceso mental completo e hizo algo completamente novedoso.
Simplemente mir al cielo, y dijo, "Disculpa, no ves que estoy conduciendo?"
"Te parece que puedo escribir una cancin ahora?
Si realmente quieres existir, regresa en un momento ms oportuno cuando me pueda encargar de ti.
Sino, ve a molestar a alguien ms.
Ve a molestar a Leonard Cohen."
Y su proceso de trabajo cambi por completo despus de eso.
No el trabajo, el trabajo an era a menudo tan oscuro como siempre.
Sino el proceso, y la pesada ansiedad a su alrededor fue liberada cuando tomo al genio, y lo saco de su interior donde solo causaba problemas, y lo liber de vuelta al lugar del que vino, y se dio cuenta que no tena que ser una cosa interiorizada, atormentadora.
Poda ser esta colaboracin peculiar, magnfica, extraordinaria tipo de conversacin entre Tom y la extraa cosa externa que no era precisamente Tom.
As que cuando o esa historia, empez a cambiar un poco la manera en que yo trabajaba, y ya me salv una vez.
No solo malo, sino el peor libro jams escrito.
Y empec a pensar que debera de dejar el proyecto.
Pero me acord de Tom hablandole al aire y lo intent.
As que levante mi cara del manuscrito y dirig mis comentarios a una esquina vaca del cuarto.
Y dije en voz alta: "Escucha t, cosa, ambos sabemos que si este libro no es brillante no es enteramente mi culpa, verdad?
Porque puedes ver que estoy poniendo todo lo que tengo en esto, no tengo nada ms.
As que si quieres que sea mejor, tienes que aparecer y cumplir con tu parte del trato.
OK. Pero si no lo haces, sabes, al diablo con esto.
Voy a seguir escribiendo porque es mi trabajo.
Y quisiera que quede reflejado hoy que yo estuve aqu para hacer mi parte del trabajo."
Porque -- al final es algo as, OK -- hace siglos en los desiertos de frica del Norte, la gente se juntaba en bailes sagrados con msica a la luz de la luna que continuaban durante horas y horas hasta el amanecer.
Y siempre eran magnficos, porque los bailarines eran profesionales y eran geniales, verdad?
Pero de vez en cuando, muy raramente, algo pasaba, y uno de estos interpretes se volvera trascendente.
Y yo s que ustedes saben de lo que estoy hablando, porque s que todos han visto, en algn momento, una ejecucin as.
Era como si el tiempo se detuviera, y el bailarn pasaba por un tipo de portal y no estaba haciendo nada diferente de lo que haba hecho las mil noches anteriores, pero todo se alineaba.
Y de repente, no pareca ser un simple humano.
Estaba iluminado internamente y desde abajo y todo iluminado con divinidad.
Y cuando esto pasaba, en esos tiempos, la gente saba lo que era, saben, y lo llamaban por su nombre.
Juntaban sus manos y empezaban a cantar, "Allah, Allah, Allah, Dios, Dios, Dios."
Eso es Dios, saben?
Una curiosa nota histrica -- Cuando los moros invadieron el sur de Espaa, llevaron esta costumbre con ellos y la pronunciacin cambi con los siglos de "Allah, Allah, Allah" a "Ol, ol, ol," Que an se escucha en plazas de toros y bailes flamencos.
En Espaa, cuando alguien ha hecho algo imposible y mgico, "Allah, ol, ol, Allah, magnfico, bravo," incomprensible, ah est -- una visin de Dios.
Lo que es grandioso, porque lo necesitamos.
Pero, la parte difcil viene a la maana siguiente, para el mismo bailarn, cuando se despierta y descubre que es martes a las 11 a.m., y l ya no es una visin de Dios.
Es solamente un mortal con malas rodillas, y tal vez jams lograr ascender a esas alturas de nuevo.
Y tal vez nadie ms cantar el nombre de Dios mientras da vueltas, Y qu va a hacer con el resto de su vida entonces?
Esto es difcil.
Es una de las reconciliaciones ms dolorosas en la vida creativa.
Pero tal vez no debe estar lleno de angustia si ustedes no creyeran, en primer lugar, que los aspectos ms extraordinarios de su ser vinieron de ustedes.
Pero tal vez si simplemente se creyeran que era un prstamo de alguna fuente inimaginable por una exquisita porcin de su vida para entregar a alguien ms cuando hubieran terminado.
Y saben, si pensamos de esta manera, empieza a cambiar todo.
As es como he empezado a pensar, y es definitivamente como he pensado en los ltimos meses mientras he trabajado en el libro que pronto ser publicado, como la peligrosa, atemorizante sobreanticipada secuela de mi extrao xito.
Y lo que tengo que seguir dicindome cuando realmente me pongo nerviosa es, no tengas miedo.
No te abrumes. Solo haz tu trabajo.
Contina presentndote para hacer tu parte, sea cual sea.
Si tu trabajo es bailar, haz tu baile.
Si el divino, absurdo genio asignado a tu caso decide dejar que se vislumbre algn tipo de maravilla, aunque sea por un momento a travs de tus esfuerzos, entonces "Ol!"
Y si no, haz tu baile de todas formas.
Y "Ol!" para ti, de todas formas.
Creo en esto y siento que debemos ensearlo.
"Ol!" a ti, de todas formas, solamente por tener el amor y la tenacidad humana de continuar intentndolo.
Gracias.
Gracias.
June Cohen: Ol!
Saben, he hablado de algunos de estos proyectos antes, sobre el genoma humano y lo que podra significar y sobre el descubrimiento de nuevos conjuntos de genes.
Estamos realmente comenzando a partir de un nuevo punto: hemos estado digitalizando la biologa y ahora estamos tratando de pasar de ese cdigo digital a una nueva fase de la biologa, diseando y sintetizando vida.
Por lo tanto, siempre hemos estado tratando de plantear grandes preguntas.
Qu es la vida? es algo que creo que muchos bilogos han tratado de entender a distintos niveles.
Hemos intentado varios mtodos, reducindola a sus componentes mnimos.
Llevamos ya casi veinte aos digitalizndola. Cuando secuenciamos el genoma humano se pasaba del mundo analgico de la biologa al mundo digital del ordenador.
Ahora estamos tratando de plantear si podemos regenerar la vida o si podemos crear nueva vida a partir de este universo digital.
Este es el mapa de un pequeo organismo, Mycoplasma genitalium, que tiene el genoma ms pequeo de todas las especies que pueden autorreplicarse en el laboratorio. Y hemos tratado de ver slo si si podemos llegar a un genoma an menor.
Somos capaces de silenciar del orden de un centenar de genes de los 500 ms o menos que tenemos aqu.
Pero cuando nos fijamos en su mapa metablico, es relativamente simple en comparacin con el nuestro. Cranme, esto es sencillo. Pero cuando nos fijamos en todos los genes que podemos silenciar de uno en uno, es muy poco probable que esto pueda dar lugar a una clula viva.
Por lo tanto, decidimos que la nica manera de avanzar era sintetizar de verdad este cromosoma para que pudisemos variar sus componentes y poder plantearnos algunas de estas preguntas ms fundamentales.
Y as iniciamos el camino de Podemos sintetizar un cromosoma?
Puede la qumica hacer posible que fabriquemos estas molculas realmente grandes llevndonos donde nunca habamos estado antes?
Y si lo hacemos, podemos hacer que arranque un cromosoma?
Un cromosoma, por cierto, no es ms que un pedazo de materia qumica inerte.
Por lo tanto, nuestro ritmo de digitalizacin de la vida ha ido aumentando a un ritmo exponencial.
Nuestra capacidad para escribir el cdigo gentico ha ido avanzando muy lentamente, pero ha ido aumentando. Y nuestro ltimo punto lo pondra ahora en una curva exponencial.
Empezamos esto hace ms de 15 aos.
Tuvo varias etapas, de hecho, comenzando con una revisin biotica antes de que hiciramos los primeros experimentos.
Pero resulta que sintetizar ADN es muy difcil.
Hay decenas de miles de mquinas en todo el mundo que fabrican trozos pequeos de ADN, de entre 30 y 50 letras de longitud, y que es un proceso que degenera, de modo que cuanto ms larga hagamos la pieza, ms errores va a haber.
As que tuvimos que crear un nuevo mtodo para juntar estos pedacitos y corregir todos los errores.
Y este fue nuestro primer intento: empezamos con la informacin digital del genoma de Phi X 174.
Se trata de un pequeo virus que mata bacterias.
Diseamos las piezas, realizamos las correcciones pertinentes y obtuvimos una molcula de ADN de unas cinco mil letras.
La etapa ms emocionante lleg cuando tomamos este pedazo de materia qumica inerte, lo introdujimos en las bacterias y stas empezaron a leer este cdigo gentico y fabricaron partculas virales.
A continuacin las partculas virales se liberaron de las clulas y luego regresaron y mataron a las E. coli.
Hace poco estuve hablando con la gente de la industria del petrleo y les dije que ellos entendan claramente este modelo.
Ellos se rieron an ms de lo que ustedes se ren ahora. Y as creemos que esta es una situacin en la que el software puede realmente construir su propio hardware en un sistema biolgico.
El diseo es fundamental, y si ests partiendo de informacin digital del ordenador, esta informacin digital tiene que ser muy precisa.
La primera vez que secuenciamos este genoma en 1995, el nivel de precisin era de un error por cada 10.000 pares de bases.
En realidad, al resecuenciarlo encontramos 30 errores. Si hubiramos utilizado esa secuencia original, nunca habra podido ponerse en funcionamiento.
Parte del diseo consiste en disear piezas que tengan 50 letras de longitud y que tienen que solaparse con las otras piezas de 50 letras para construir subunidades ms pequeas que tuvimos que disear de manera que puedan ir juntas.
Diseamos elementos nicos para ello.
Quizs hayan ledo que les ponemos marcas de agua.
Piensen en esto: tenemos un cdigo gentico de cuatro letras: A, C, G y T.
Los tripletes de esas letras codifican aproximadamente veinte aminocidos, hay una sola designacin de letras para cada uno de los aminocidos.
As que podemos usar el cdigo gentico para escribir palabras, frases, pensamientos.
Inicialmente, todo lo que hicimos fue autografiarlo.
Algunos estaban decepcionados porque no haba poesa.
Diseamos estas piezas de manera que pudisemos digerirlas slo con enzimas. Hay enzimas que las repararan y las juntan.
Y empezamos a hacer piezas empezamos con piezas que iban desde 5.000 hasta 7.000 letras, las acoplamos para hacer piezas de 24.000 letras y luego juntamos dichos conjuntos llegando a 72.000 letras.
En cada etapa, sintetizamos abundantes piezas de stas para poder secuenciarlas, porque estamos tratando de crear un proceso que sea muy slido y que van a ver en un minuto.
Estamos tratando de llegar al punto de la automatizacin.
As pues, esto se parece a un playoff de baloncesto
Cuando nos ponemos con estas piezas muy grandes de ms de 100,000 pares de bases ya no van a crecer tan fcilmente en E. coli. Este proceso agota todas las herramientas modernas de la biologa molecular. As que recurrimos a otros mecanismos.
Sabamos que hay un mecanismo llamado recombinacin homloga, utilizado por la biologa para reparar el ADN, que puede juntar estas piezas.
Aqu tenemos un ejemplo de ello. Hay un organismo llamado Deinococcus radiodurans que puede soportar hasta tres millones de rads de radiacin.
Como pueden ver en el panel superior, simplemente se hace explotar su cromosoma.
De doce a veinticuatro horas despus, se vuelve a reconstituir, exactamente como estaba antes.
Tenemos miles de organismos que pueden hacer lo mismo.
Estos organismos pueden desecarse totalmente. O pueden vivir en el vaco.
Estoy completamente seguro de que puede existir vida en el espacio sideral, vida que puede desplazarse, encontrar un nuevo medio acuoso.
De hecho, la NASA ha demostrado que esto ocurre.
Aqu pueden ver una micrografa real de la molcula que construimos utilizando estos procesos, en realidad utilizando slo mecanismos de las levaduras con el diseo adecuado de las piezas que pusimos en ellas. Las levaduras las juntan automticamente.
Esto no es una micrografa electrnica, se trata tan slo de una fotomicrografa normal.
Es una molcula tan grande que podemos verla slo con un microscopio ptico.
Estas son imgenes tomadas a lo largo de un periodo de unos seis segundos.
As que esta es la publicacin que presentamos hace poco.
Son ms de 580,000 letras del cdigo gentico. Es la molcula ms grande jams sintetizada por el hombre de una estructura determinada.
Tiene una masa molecular superior a 300 millones.
Si imprimisemos su cdigo gentico con un tamao de fuente de diez y sin espacios, haran falta 142 pginas nada ms que para imprimir este cdigo gentico.
Bien, y cmo logramos que arranque un cromosoma? Cmo lo activamos?
Obviamente, con un virus es bastante sencillo. Pero es mucho ms complicado cuando se trata de bacterias.
Tambin es ms sencillo cuando pasas a eucariotas como nosotros: puede bastar con quitar el ncleo y meterle otro, y eso es de lo que todos han odo hablar con la clonacin.
Con las arqueobacterias, el cromosoma est integrado en la clula, pero recientemente hemos demostrado que podemos hacer un trasplante de un cromosoma de una clula a otra y activarlo.
el nuevo cromosoma entr en la clula.
De hecho, pensamos que esto sera lo ms lejos que llegaramos, pero hemos tratado de disear el proceso para llegar un poco ms lejos.
Aqu se trata de un importante mecanismo de la evolucin.
Encontramos todo tipo de especies que han incorporado un segundo o un tercer cromosoma procedente de algn lugar, aadiendo miles de nuevos caracteres a esas especies en cuestin de segundos.
As que la gente que piensa en la evolucin como un simple cambio de un gen cada vez no ha entendido mucho la biologa.
Hay enzimas llamadas enzimas de restriccin que realmente digieren el ADN.
El cromosoma que se encontraba en la clula careca de ellas. La clula el cromosoma que pusimos en ella s las tiene.
El cromosoma se expres y reconoci el otro cromosoma como material extrao, lo digiri y as logramos que en la clula slo quedara el nuevo cromosoma.
Y ste se volvi azul debido a los genes que pusimos en l.
Y en un perodo muy corto de tiempo, todas las caractersticas de una de las especies se haban perdido y dicha especie se ha convertido totalmente en la nueva especie basada en el nuevo software que habamos puesto en la clula.
Todas las protenas cambiaron, las membranas cambiaron y cuando leemos el cdigo gentico, ste es exactamente el que habamos transferido.
As que esto puede sonar como alquimia genmica, pero podemos, cambiando de sitio el ADN software, cambiar las cosas de manera bastante espectacular.
Ahora bien, he argumentado, no se trata del gnesis: esto se basa en tres mil quinientos millones de aos de evolucin,
y he argumentado que puede que estemos a punto de tal vez crear una nueva versin de la explosin Cmbrica, en la que se produce una nueva especiacin a gran escala basada en este diseo digital.
Por qu hacer esto?
Creo que esto es bastante evidente en trminos de algunas de las necesidades.
Vamos a pasar de seis mil quinientos millones a nueve mil millones de personas en los prximos cuarenta aos.
Ponindolo en mi propio contexto: nac en 1946.
Ahora hay tres personas en el planeta por cada uno de los que existamos en 1946; dentro de cuarenta aos, habr cuatro.
Tenemos problemas para alimentar, suministrar agua potable, medicamentos o combustible a estos seis mil quinientos millones de personas.
Habr que hacer un gran esfuerzo si queremos hacerlo para nueve mil millones.
Utilizamos ms de cinco mil millones de toneladas de carbn, ms de treinta mil millones de barriles de petrleo (al ao). Esto equivale a unos cien millones de barriles al da.
Cuando tratamos de pensar en procesos biolgicos o en cualquier tipo de proceso que los sustituya, va a ser un reto tremendo.
Luego, por supuesto, viene todo el CO2 procedente de este material que acaba en la atmsfera.
Ahora, a partir de nuestro descubrimiento en todo el mundo, tenemos una base de datos con alrededor de veinte millones de genes y a m me gusta pensar en ellos como en los componentes para disear el futuro.
La industria electrnica slo contaba con una docena de componentes y fjense en la diversidad que sali de eso.
En este punto estamos principalmente limitados por una realidad biolgica y nuestra imaginacin.
Ahora disponemos de tcnicas, gracias a estos mtodos de sntesis rpidos, para hacer lo que estamos denominando genmica combinatoria.
Ahora tenemos la capacidad de construir un gran robot que puede fabricar un milln de cromosomas al da.
Cuando se piensa en procesar estos veinte millones de genes diferentes o en tratar de optimizar los procesos para la produccin de octano o de productos farmacuticos, nuevas vacunas, podemos cambiar, haciendo slo con un pequeo equipo ms biologa molecular que durante los ltimos 20 aos de ciencia.
Y esto slo en cuanto a la seleccin normal. Podemos seleccionar para su viabilidad, la produccin de sustancias qumicas y combustibles, la produccin de vacunas, etc.
Esta es una pantalla que resume la informacin de algunos programas de diseo reales en los que estamos trabajando para ser de verdad capaces de sentarnos a disear especies en el ordenador.
No sabemos necesariamente qu aspecto tendrn. Sabemos exactamente cmo ser su cdigo gentico.
Ahora estamos centrados en los combustibles de cuarta generacin.
Hemos visto recientemente que el etanol de maz es slo un mal experimento.
Tenemos combustibles de segunda y tercera generacin que saldrn relativamente pronto y que van desde el azcar hasta combustibles de mucho mayor valor como el octano o los diferentes tipos de butanol.
Pero pensamos que la nica manera en que la biologa puede tener un impacto importante, sin aumentar an ms el coste de los alimentos y la limitacin de su disponibilidad, es que comencemos con el CO2 como materia prima, por lo que estamos trabajando en el diseo de clulas para seguir por esta va
y creemos que tendremos los primeros combustibles de cuarta generacin en aproximadamente ao y medio.
Luz solar y CO2 es un mtodo
, pero en nuestro descubrimiento por todo el mundo, tenemos toda clase de mtodos diferentes.
ste es un organismo descrito en 1996.
Vive en las profundidades del ocano, a una milla y media de profundidad, a temperaturas cercanas al punto de ebullicin del agua.
Convierte el CO2 en metano utilizando hidrgeno molecular como fuente de energa.
Estamos tratando de ver si podemos tomar el CO2 capturado, que puede llevarse fcilmente por tuberas a los sitios de produccin, y volver a convertir este CO2 en combustible para dirigir este proceso.
As que pensamos que, en un corto perodo de tiempo, podramos ser capaces de aumentar lo que es la pregunta bsica de Qu es la vida?.
Estamos realmente, ya saben, tenemos objetivos modestos de sustitucin de toda la industria petroqumica. Claro que s! Si esto no se puede hacer en TED, dnde se va a poder? Convertirse en una importante fuente de energa.
Pero tambin estamos trabajando ahora mismo en utilizar estas mismas herramientas para llegar a series de vacunas instantneas.
Ya lo han visto este ao con la gripe, que siempre nos falta un ao y un dlar de dar con la vacuna apropiada.
Creo que esto se puede cambiar creando anticipadamente vacunas combinatorias.
Aqu tienen cmo puede empezar a parecer el futuro cambiando, ahora, el rbol evolutivo, acelerando la evolucin con bacterias sintticas, arqueobacterias y, eventualmente, eucariotas.
Estamos lejos de mejorar a las personas. Nuestro objetivo es asegurarnos de que tenemos la posibilidad de sobrevivir el tiempo suficiente para quizs hacerlo. Muchas gracias.
Aqu estamos viendo muchos, muchos gigabytes de fotos digitales, haciendo zoom en forma continua y sin dificultades, haciendo panormicas y modificaciones de cualquier tipo.
La cantidad de informacin que veamos, el tamao de las colecciones y el de las imgenes ya no son un problema.
En su mayora son fotos de cmaras digitales comunes, pero esta, por ejemplo, es una escaneada de la Biblioteca del Congreso, con cerca de 300 megapxeles.
Es lo mismo, porque lo nico que puede limitar el rendimiento de un sistema como este es el nmero de pxeles de su pantalla
en un momento dado. Tambin tiene una arquitectura muy flexible.
Este es un libro completo, un ejemplo de datos sin imgenes.
Se trata de "Casa desolada", de Dickens. Cada columna es un captulo.
Para probarles que se trata realmente de texto, y no de una imagen, podemos hacer algo para mostrar que se trata de una representacin real del texto; no es una imagen.
Quiz sea una forma algo artificial de leer un libro electrnico.
No la recomendara.
Este es un caso ms realista. Un ejemplar de The Guardian.
Cada imagen grande es el comienzo de una seccin.
Y realmente proporciona el placer y la experiencia agradable de leer la versin real en papel de una revista o un diario, un tipo de medio propiamente de escalas mltiples.
Tambin hemos hecho algo en una esquina de este ejemplar de The Guardian.
Hemos hecho un anuncio publicitario falso con alta resolucin, mucho ms de la que puede obtenerse en un anuncio comn, y le hemos incorporado otros contenidos.
Si desean ver las caractersticas de este coche, pueden hacerlo aqu.
O ver otros modelos, e incluso especificaciones tcnicas.
Esto comprende algunas de las ideas sobre anular los lmites en torno a los inmuebles en pantalla.
Esperamos que esto implique el fin de las pantallas emergentes y otros estorbos de ese tipo: ya no seran necesarios.
Por cierto, el mapeo es una de las aplicaciones realmente obvias en una tecnologa como esta.
No voy a demorarme en esto, salvo decir que tambin tenemos cmo contribuir en este campo.
Estas son todas las carreteras de los EE.UU.
sobreimpresas en la parte superior de una imagen geoespacial de la NASA.
Ahora veamos algo ms.
Esto est en directo en la red en este momento, pueden verlo.
Es un proyecto llamado Photosynth, que combina dos tecnologas diferentes.
Una es Seadragon, y la otra una investigacin visual computarizada muy hermosa, realizada por Noah Snavely, estudiante de posgrado de la Universidad de Washington, codirigida por Steve Seitz de la misma universidad
y Rick Szeliski en el Dpto. de Investigacin de Microsoft. Una muy buena colaboracin.
Y est en directo en la web, con tecnologa de Seadragon.
Pueden apreciarlo cuando hacemos estos tipos de vistas, en las que podemos bucear a travs de las imgenes y tener esta experiencia de resolucin mltiple.
El orden espacial de estas imgenes es realmente significativo.
Los algoritmos visuales computarizados registraron estas imgenes en conjunto, de modo que se corresponden con el espacio real en que se hicieron las tomas, hechas en los Lagos Grassi, en las Montaas Rocallosas canadienses.
Aqu ven elementos de diapositivas estabilizadas o imgenes panormicas, todas relacionadas espacialmente.
No s si tengo tiempo para mostrarles otros entornos.
Algunos son mucho ms espaciales.
al ver los entornos que hemos subido a la red.
Tuvimos que ocuparmos de las capas y dems. Esta es una reconstruccin de la Catedral de Notre Dame,
realizada totalmente con ordenador a partir de imgenes tomadas de Flickr. Simplemente pongan Notre Dame en Flickr,
y podrn ver imgenes de personas en camiseta, del campus y dems. Cada uno de estos conos anaranjados representa una imagen
perteneciente a este modelo. Y estas son todas imgenes de Flickr, relacionadas espacialmente de esta manera.
Podemos navegar simplemente de esta forma tan sencilla.
. Saben, nunca pens que terminara trabajando en Microsoft.
Es muy gratificante tener una recepcin as aqu.
. Supongo que sabrn que hay muchos tipos diferentes de cmaras: desde las de telfonos mviles hasta SLR profesionales, gran parte de ellas ligadas a este entorno.
Si puedo buscar algunas de las ms raras. Muchas estn bloqueadas por rostro, y dems.
Algunas de estas son realmente una serie de fotografas... veamos.
Este es en realidad un pster de Notre Dame registrado correctamente.
Podemos acercanos desde el pster hasta una vista fsica de este entorno.
Lo que importa realmente aqu es que podemos hacer algo en el entorno social. Aqu se estn tomando datos de todos,
de toda la memoria colectiva de la apariencia visual de la Tierra, y vinculndose en su totalidad. Todas estas fotos se vinculan
y producen algo emergente que es ms que la suma de las partes.
Este es un modelo que surge de toda la Tierra.
Vanlo como la larga cola del trabajo de Tierra Virtual de Stephen Lawler.
Es algo cuya complejidad crece con el uso y cuyos beneficios para los usuarios se amplan a medida que lo utilizan.
Sus propias fotos se etiquetan con metadatos que alguien introdujo.
Por supuesto, una consecuencia de todo ello consiste en modelos virtuales enormemente ricos de cada parte interesante de la Tierra, tomados no solo de vuelos de altura e imgenes satelitales y dems, sino de la memoria colectiva.
Muchas gracias.
Chris Anderson: A ver si lo comprendo bien: este software permitir en algn momento, en los prximos aos, que todas las imgenes compartidas por cualquier persona en cualquier parte del mundo se vinculen?
BAA: S. Lo que hace realmente es descubrir crear hipervnculos, si lo quieren, entre las imgenes.
Y lo hace basndose en el contenido de las imgenes.
Y es realmente emocionante pensar en la riqueza de la informacin semntica de muchas de estas imgenes.
Como en una bsqueda de imgenes en la web, se introducen frases, y el texto de la pgina web lleva gran cantidad de informacin acerca de la imagen.
Ahora, qu sucede si dicha imagen se vincula con todas sus imgenes?
La cantidad de interconexin semntica y de riqueza procedente de ello es verdaderamente enorme. Es un efecto de red clsico.
CA: Blaise, es realmente increble. Felicidades.
BAA: Muchas gracias.
Y por supuesto, compartimos los mismos pasos imperativos de la adaptacin.
Todos nacemos. Traemos nuestros hijos al mundo.
Experimentamos ritos de iniciacin.
Tenemos que afrontar la inevitable separacin que provoca la muerte. Y no debe sorprendernos que todos cantemos, bailemos, y vivamos el arte.
Pero lo que es interesante es la cadencia de las canciones, el ritmo del baile en cada cultura.
Todos estos pueblos nos ensean que existen otras formas de ser, otras formas de pensar, otras formas de orientacin en la Tierra.
Y si reflexionamos un poco sobre esta idea solo puede llenarnos de esperanza.
Ahora, junto con las miles de culturas del mundo forman un entramado espiritual y cultural que abarca todo el planeta y es tan fundamental para su bienestar como el entramado biolgico conocido como biosfera.
Y ustedes pueden pensar en llamar a este entramado de vida cultural biolgico como lo que es una etnosfera. Y la etnosfera podra definirse como la suma total de todos los pensamientos, sueos, mitos, ideas, inspiraciones e intuiciones que han cobrado forma gracias a la imaginacin humana desde el principio de su conciencia.
La etnosfera es el gran legado de la humanidad.
Es el smbolo de todo lo que somos y lo que podemos ser como especie sumamente curiosa.
Y de igual modo que la biosfera est sufriendo un grave proceso de erosin, la etnosfera tambin padece este proceso, a un ritmo incluso ms rpido.
Y un gran indicador de esta situacin es la prdida de idiomas en el mundo.
Cuando naci cada uno de los presentes en esta sala haba 6000 idiomas hablados en el planeta.
Una lengua no es simplemente un conjunto de palabras o reglas gramaticales.
Una lengua es un destello del espritu humano,
el vehculo mediante el cual viene a nuestro mundo material el alma de cada cultura particular.
Es una fuerza generadora de la mente, un cauce, un pensamiento y un ecosistema de posibilidades espirituales.
Y de los 6000 idiomas, mientras estamos sentados aqu en Monterey, ms de la mitad ya no se susurrarn a los odos de los nios.
Ya no se ensean estos idiomas a los nios, lo que significa efectivamente, excepto que algo cambie, que estos idiomas estn prcticamente muertos.
Qu podra ser ms solitario que estar envuelto en el silencio, ser el ltimo hablante de tu propia lengua, y no poder transmitir el conocimiento de los ancestros o anticipar el futuro de los nios?
Y peor an es el horrible destino de alguien cada dos semanas, en un lugar del mundo, porque cada quince das, fallece un anciano que se lleva con l a la tumba las ltimas slabas de una antigua lengua.
Y s que algunos de ustedes consideran que quiz el mundo sera un mejor lugar si todos hablramos la misma lengua Y yo respondo: Genial!" Pero que este idioma sea el yoruba o sea el cantons
o el kogi.
Entonces todos descubriramos lo que sera no poder hablar nuestro propio idioma.
Y por eso, lo que me gustara hacer hoy es algo as como llevarlos de paseo por la etnosfera. Un breve paseo a travs de la etnosfera para darles una idea de lo que realmente se est perdiendo.
Ahora, muchos de nosotros solemos olvidar que cuando digo "distintas realidades" realmente quiero decir distintas realidades.
Tomemos por ejemplo, este nio de Barasana al noroeste del Amazonas, el pueblo de la anaconda, que creen, segn su mitologa, que vinieron de un ro de Leche, procedentes del Este, del vientre de las serpientes sagradas.
Estas son personas que cognitivamente no distinguen el color azul del verde, porque el dosel del cielo se confunde con el bosque del cual depende su existencia.
Tienen una curiosa costumbre lingstica matrimonial denominada "exogamia lingstica": deben casarse con alguien que hable otra lengua.
Y todo esto se debe al pasado mitolgico y lo curioso es que en cada choza comunitaria donde se hablan hasta seis o siete idiomas por la endogamia, no se escucha a nadie practicando un idioma.
Simplemente escuchan hasta que un da empiezan a hablar.
O una de las tribus ms fascinantes con las que he vivido son los waorani que viven al noreste de Ecuador. Un pueblo sorprendente con el que se tuvo un primer contacto pacficamente, en 1958.
En 1957, cinco misioneros intentaron entrar en contacto con ellos y cometieron un grave error.
Lanzaron desde el avin fotos en las que aparecan ellos, en actitud amistosa, sin tener en cuenta que aquel pueblo de la selva tropical jams haba visto un objeto bidimensional.
Recogieron las fotos del suelo de la selva, las miraron por detrs de los rostros, buscando el resto de la forma o la figura humana y al no encontrar nada, concluyeron que se trataba de tarjetas de visita del diablo. Entonces mataron con sus lanzas a los cinco misioneros.
Pero los waorani no solo mataban con sus lanzas a los extranjeros.
Se mataban entre s.
El 54% de la mortalidad del pueblo se debi a la matanza mutua.
Sus cazadores podan oler la orina de los animales a 40 pasos y podan decir de qu especie se trataba.
A comienzos de 1980, me dieron una misin realmente sorprendente Un profesor de Harvard me pregunt si me interesara ir a Hait, infiltrarme en las sociedades secretas, que eran la base del poder de Duvalier y los Tonton Macoutes, y proteger el veneno utilizado para crear zombies.
Para entender lo que se me peda, tena que conocer algo de esta notable religin: el vud. Y el vud no es un culto de magia negra.
Por el contrario, es una compleja visin metafsica del mundo
Es interesante.
Si les pidiera que nombraran las grandes religiones del mundo qu diran?
cristianismo, islam, judasmo, budismo, etc.
Siempre nos olvidamos de un continente, frica como asumiendo que los africanos del Sub-Shara no tienen fe religiosa, aunque evidentemente s la tienen. El vud es simplemente la sntesis de estas profundas ideas religiosas que surgieron durante la trgica dispora en los tiempos de la esclavitud.
Pero, lo que hace al vud tan apasionante es que es una relacin dinmica entre los vivos y los muertos.
Los vivos dan origen a los espritus.
Los espritus se pueden invocar desde debajo del Gran Agua respondiendo al ritmo de los bailes para desplazar momentneamente el alma de los vivos, para que en ese breve pero brillante momento, el aclito se convierta en dios.
Por eso es que a los vudistas les gusta decir que "Ustedes los blancos van a la iglesia y hablan de Dios.
Nosotros nos convertimos en Dios en el templo".
Y al estar posedos, el espritu los toma, Cmo les hara dao?
Uno ve estas demostraciones sorprendentes: aclitos del vud en estado de trance manipulando las brasas ardientes sin lastimarse, un ejemplo asombroso de la capacidad de la mente para dominar el cuerpo cuando se cataliza en el estado de extrema excitacin.
De todos los pueblos que he visitado, los ms extraordinarios son los kogi de la Sierra Nevada de Santa Marta al norte de Colombia.
Son descendientes de la antigua civilizacin tairona, que antao se extenda por toda la costa caribea colombiana. Huyendo de los espaoles de la conquista, los kogi se refugiaron en un aislado macizo volcnico que sobresale en la costa caribea.
En un continente teido de sangre por las conquistas estas personas nunca fueron conquistadas por los espaoles.
Hasta la actualidad conservan como sistema de gobierno el sacerdocio ritual. El proceso de formacin de los sacerdotes es extraordinario.
Y durante todo este tiempo, se les ensea los valores de su sociedad, los valores que conservan la premisa de que sus oraciones y solo sus oraciones mantienen el equilibrio csmico... o deberamos decir ecolgico.
Es hermoso y a vosotros os toca protegerlo.
Se autodenominan hermanos mayores y dicen que nosotros somos los hermanos menores porque segn ellos, somos los responsables estar destruyendo el mundo.
Este nivel de intuicin es muy importante.
Cuando pensamos en los indgenas y el medio ambiente, invocamos a Rousseau y la vieja mentira de un salvaje aristocrtico lo cual es una idea racista en su simplicidad o de forma alternativa, invocamos a Thoreau y decimos que estas personas estn ms cerca de la Tierra que nosotros.
En realidad, los indgenas no son sentimentales ni son dbiles por la nostalgia.
Qu significa eso?
Si esa montaa es el hogar de un espritu o una pila de minerales es irrelevante.
Lo que es interesante es la metfora que define la relacin entre el individuo y el mundo natural.
Yo crec en los bosques de Columbia Britnica donde se crea que esos bosques existan para talarse.
Eso me hizo un ser humano diferente a mis amigos, los kwakiutl, que creen que esos bosques son el hogar de Hukuk y los pjaros sagrados adems de los espritus canbales que habitaban la parte norte del mundo con quienes deban comprometerse estas comunidades durante su iniciacin Hamatsa.
Ahora, si comenzamos a pensar que estas culturas pueden crear realidades diferentes, podemos empezar a entender algunos de sus extraordinarios descubrimientos. Tomemos esta planta.
Es una foto que tom al noroeste del Amazonas en abril pasado.
Esta es la ayahuasca, muchos de ustedes pueden haber odo hablar de ella. La preparacin psicoactiva ms poderosa del repertorio de un chamn.
Esta planta tiene triptaminas muy poderosas muy parecidas a la cerotonina del cerebro, dimetiltriptamina-5 metoxidimetiltriptamina.
Si alguna vez han visto a los yanomami aspirando esa sustancia por sus narices esa sustancia fue creada de un conjunto de diversas especies que tambin contienen metoxidimetiltriptamina.
Tener que inhalar ese polvo es como salir disparado por el can de una escopeta y al mismo estar inmerso en pinturas barrocas y aterrizar en un mar de electricidad. No crea la distorsin de la realidad sino una disolucin de ella.
Solo se puede ingerir de forma oral en conjunto con otros qumicos que desnaturalicen los MAO o monoaminocidos.
Ahora, lo fascinante de esto es que los componentes qumicos de esta liana son precisamente los inhibidores MAO necesarios para potenciar las triptaminas. Entonces, uno se pregunta:
Cmo pudo ser que en una flora de 80 000 especies de plantas, estas personas encontraron 2 plantas morfolgicamente no relacionadas, que cuando se combinan de esta manera crean un tipo de versin bioqumica de un todo que es ms mayor que la suma de sus partes?
En este caso, utilizamos el conocido eufemismo, prueba y error que en realidad no tiene mucho sentido.
Pero si le preguntamos a un indgena, nos contestar: Las plantas nos lo dijeron".
Pero qu significa eso?
Los kofan reconocen hasta 17 variedades de esta liana, las cuales distinguen a gran distancia en el bosque. Todas las que nosotros distinguiramos como solo una especie.
Y les pregunt cmo establecen su taxonoma y me contestaron: Pensbamos que sabas algo de plantas".
Pero es que no sabes nada? Y yo dije, "No".
Entonces me dijeron que uno toma cada una de las 17 especies en una noche de luna llena y ellas le cantarn en una meloda distinta.
Con el paso del tiempo, las culturas cambian constantemente hacia nuevas posibilidades de vida.
Y el problema no es la tecnologa.
Los indios Sioux no dejaron de serlo cuando dejaron el arco y la flecha Tampoco los norteamericanos dejaron de serlo cuando dejaron de utilizar la carreta.
No es el cambio ni la tecnologa lo que amenaza la integridad de la etnosfera. Es el poder. La cruda cara de la dominacin.
O si vamos a las montaas del Tbet donde estoy realizando muchas investigaciones recientemente, veremos que es la cruda cara del dominio poltico.
Ustedes saben, el genocidio, la extincin fsica de un pueblo, est universalmente condenado pero el etnocidio, la destruccin del estilo de vida de un pueblo, no solo no es condenado universalmente sino que en muchos lugares es celebrado como parte de una estrategia de desarrollo.
Y no se entiende el dolor del Tbet hasta que uno lo atraviesa por tierra.
El padre de este joven haba sido relacionado con el Panchen Lama,
lo que significaba que fue asesinado casi instantneamente en el momento de la invasin china.
Su to haba huido con su santidad en la dispora que hizo desaparecer al pueblo de Nepal.
Su madre fue encarcelada por cometer el crimen de ser rica.
l mismo fue encarcelado de contrabando a la edad de dos aos y se esconda entre las faldas de su madre porque ella no poda estar sin l.
La hermana quien haba realizado esa hazaa fue recluida en un campo de educacin.
Un da, pis sin querer un brazalete de Mao y por su trasgresin fue condenada a siete aos de trabajos forzados.
El dolor del Tbet puede ser casi imposible de soportar pero el espritu redentor del pueblo es algo para destacar.
Y al final del mismo, se trata de una simple eleccin. Deseamos vivir en un mundo monocromtico y montono o queremos un mundo policromo y diversificado?
Y es humilde recordar que nuestra especie ha existido durante [150 000] aos.
La revolucin neoltica que nos dio la agricultura, y que al tiempo nos hizo sucumbir en el culto a la semilla, desapareci la poesa del chamn y apareci la prosa del clero, hemos creado un excedente de especializaciones jerrquicas... ...fue hace solo 10 000 aos.
El mundo moderno como lo conocemos tiene tan solo 300 aos de antigedad
Esta historia superficial no me sugiere que tenemos todas las respuestas para todos los desafos a los que nos enfrentaremos en los prximos milenios.
Cuando preguntamos a esta variedad de culturas del mundo el significado de ser humano responden con 10 000 voces diferentes.
Y es con esa actitud que volveremos a descubrir la posibilidad de ser lo que somos: una especie totalmente consciente de que debemos proteger todos los pueblos y todos los jardines para que encuentren una forma de florecer. Y existen grandes momentos de optimismo.
Esta es una fotografa que tom en la punta norte de la isla Baffin cuando fui a cazar narvales con varios inuits y este hombre, Olaya, me cont una maravillosa historia de su abuelo.
El gobierno canadiense no siempre fue considerado con el pueblo inuit y durante la dcada de 1950, con el fin de establecer nuestra soberana, los obligamos a vivir en asentamientos.
El abuelo de este hombre rehus a irse.
La familia, que tema por su vida, sac todas sus armas y todas sus herramientas.
Deben recordar que los inuits no tienen miedo del fro. Por el contrario, lo aprovechan.
Originalmente las cubiertas de sus trineos eran de pescado envueltas en cuero de carib.
Entonces, el abuelo de mi gua no fue intimidado por la noche rtica ni la tormenta de nieve que soplaba.
Simplemente se qued fuera, se baj los pantalones de piel de foca y defec en su mano. Y las heces comenzaron a congelarse. Les dio forma de cuchillo.
y coloc un poco de saliva al borde del cuchillo de materia fecal Cuando estuvo slido por el congelamiento, mat un perro.
Lo desoll e improvis un arns, utiliz las costillas del perro e improvis un trineo tirado por otro perro y desapareci entre los tmpanos con el cuchillo de materia fecal en la cintura.
Hablando de subsistir con nada... Y este, en muchas formas, es un smbolo de la resistencia del pueblo inuit y de todos los pueblos indgenas del mundo.
En abril de 1999, el gobierno de Canad devolvi el control total de un rea ms grande que California y Texas juntas a los inuits.
Es nuestro nuevo hogar. Se llama Nunavut.
Es un territorio independiente. Ellos controlan los recursos minerales.
Este es un ejemplo excelente de cmo una nacin-estado puede llegar y restituir a su pueblo lo que les pertenece.
Y finalmente, creo que es muy obvio... al menos para todos los que viajamos a los confines del planeta darse cuenta de que estos lugares remotos no lo son en absoluto.
Son el hogar de alguien.
Representan una parte de la imaginacin humana que se remonta al inicio de los tiempos. Y para todos nosotros, los sueos de estos nios, al igual que los sueos de nuestros propios hijos forman parte de la geografa viva de la esperanza.
Lo que tratamos finalmente de hacer en National Geographic es, creemos que los polticos nunca lograrn nada.
Consideramos creemos que la polmica no es persuasiva, pero creemos que los relatos pueden cambiar el mundo. Por eso quizs somos la mejor institucin contando historias en el mundo. Hay 35 millones de visitas en nuestro sitio web cada mes.
156 naciones tienen nuestro canal de televisin.
Millones de personas leen nuestras revistas.
Muchas gracias.
Les voy a hablar acerca de algo que est en uno de mis libros que espero resonar con otras cosas que ustedes han escuchado, e intentar hacer algunas conexiones yo mismo, en caso de que ustedes las pierdan.
Quiero empezar con lo que llamo el "dogma oficial".
El dogma oficial de qu?
El dogma oficial de todas las sociedades industriales occidentales.
Y el dogma oficial dice as: Si estamos interesados en maximizar el bienestar de nuestros ciudadanos, la manera de hacerlo es maximizar la libertad individual.
La razn de esto es tanto que la libertad en s misma es buena, como valiosa, loable y esencial a los seres humanos.
Y porque si la gente tiene libertad, entonces cada uno de nosotros puede actuar por nuestra cuenta para hacer las cosas que maximizarn nuestro bienestar y nadie tendr que decidir en nuestro nombre.
La forma de maximizar libertad es maximizando la eleccin.
Entre ms posibilidades tenga la gente, ms libertad tendr y entre ms libertad tenga, ms bienestar tendrn.
Esta idea, pienso, est tan profundamente integrada en el abasto de agua que a nadie se le ocurrira cuestionarlo.
Y tambin est profundamente integrado en nuestras vidas.
Les dar algunos ejemplos de cmo el progreso moderno lo ha hecho posible para nosotros
Este es mi supermercado. No es tan grande.
Quisiera decir unas palabras acerca de los aderezos de ensalada.
Hay 175 aderezos de ensalada en mi supermercado. Eso si no contamos los 10 diferentes tipos de aceite de oliva extra virgen y los 12 vinagres balsmicos que pueden comprar. para que hagan su propia gran variedad de aderezos, en el caso remoto de que ninguna de las 175 que ofrece la tienda les guste.
Y as es como es en el supermercado.
Y luego vayan a la tienda de electrodomsticos para ver los sistemas estereofnicos, bocinas, reproductores de CD, de cintas, sintonizador, amplificador. Y esto en una sola tienda de electrodomsticos, tienen esta cantidad de sistemas estereofnicos.
Podemos construir seis y medio millones de sistemas de estreo diferentes con los componentes que se ofrecen en una sola tienda.
Reconozcamos que hay mucho para elegir.
En otros campos, el mundo de las comunicaciones.
Hubo una poca, cuando era nio, cuando uno poda obtener cualquier tipo de servicio telefnico que quisiera, siempre y cuando viniera de Ma Bell.
Uno rentaba el telfono. No lo compraba.
Una consecuencia de esto, por cierto, es que el telfono nunca se descompona
Esos tiempos ya se fueron.
Ahora tenemos una casi ilimitada variedad de aparatos telefnicos, especialmente en el mundo de los celulares.
Estos son los celulares del futuro.
Mi favorito es el de en medio, con reproductor MP3, rasuradora de pelos de la nariz, encendedor para creme brulee.
Y si por si acaso no lo han visto en su tienda todava, les puedo asegurar que pronto algn da lo tendr.
Y lo que esto hace es conducir a la gente a entrar a las tiendas hacindose esta pregunta.
Y saben cul es ahora la respuesta a esta pregunta?
La respuesta es "No."
No es posible comprar un celular que no haga demasiado.
As, en otros aspectos de la vida que son mucho ms significativos que comprar cosas, la misma explosin de posibilidades es cierta.
Servicios de salud, ya no es ms el caso en Estados Unidos cuando uno iba al doctor y el doctor le deca a uno qu hacer.
En su lugar, uno va al doctor y el doctor dice, bueno, podramos hacer A B.
A tiene estos beneficios y estos riesgos
B tiene estos beneficios y estos riesgos qu quiere hacer?
Y uno dice: "Doc qu debo hacer?"
Y el doc dice: A tiene estos beneficios y estos riesgos y B tiene estos beneficios y estos riesgos.
Qu quiere hacer?
Y uno dice: "Si usted fuera yo, Doc, qu hara?"
Y el doc dice: "Pero yo no soy usted."
Existe una enorme mercadotecnia de los medicamentos recetados para personas como ustedes y yo, que si lo piensan, no tiene sentido en absoluto, porque no podemos comprarlos sin recetas.
Por qu nos los mercadean si no los podemos comprar?
La respuesta es que esperan que llamemos a nuestros doctores el da siguiente y pidamos que nos cambie la receta.
Algo tan drstico como nuestra identidad se ha vuelto ahora una cuestin de elegir, como lo indica esta diapositiva.
No heredamos una identidad, tenemos que inventarla.
Y nos reinventarnos con la frecuencia con la que queremos.
Y esto significa que cada da cuando nos despertamos en la maana, tenemos que decidir que clase de persona queremos ser.
Con respecto al matrimonio y a la familia, hubo un tiempo que la suposicin por omisin que casi todos tenan es que te casabas tan pronto como podas, luego empezabas a tener hijos tan pronto como podas.
La nica eleccin real era quien, no cuando y no lo que haras despus.
Hoy en da, todo est ms a nuestra dispocicion.
Doy clases con mucha fortuna a estudiantes inteligentes, y les asigno 20% menos trabajo de lo que sola hacer.
Y no es porque sean menos listos, y tampoco porque sean menos diligentes,
Es porque estn preocupados, preguntndose, Debo casarme o no? Debo casarme ahora?
O debo casarme despus? Primero los hijos o la carrera?
Todas estas son preguntas avasalladoras.
Y las tienen que contestar, aun cuando hagan o no todo el trabajo que les asigno y no obtengan buenas calificaciones en sus cursos.
En efecto tienen que hacerlo. Estas son preguntas importantes a responder.
Trabajo, somos benditos, como lo apuntaba Carl, con la tecnologa que nos permite trabajar cada minuto del da desde cualquier lugar del planeta excepto el Hotel Randolph.
Existe una esquina, por cierto pero no se los voy a contar, donde el WiFi funciona.
Y no se los voy a decir porque yo quiero usarlo.
Lo que esto significa, esta increble libertad de eleccion que tenemos con respecto al trabajo, es que tenemos que tomar una decisin, una y otra vez y otra vez acerca de si debemos o no trabajar.
Podemos ir a ver a nuestros hijos jugar futbol, y tener nuestro celular en una cadera, y nuestro Blackberry en la otra, y nuestra laptop, supuestamente, en nuestro regazo.
Incluso si los tuviramos apagados, cada minuto en que estemos viendo a nuestro hijo mutilar un partido de futbol, nos estaremos preguntando, "Debo contestar el celular?"
"Debo responder el correo? Debo hacer el borrador de la carta?"
Incluso si la respuesta a la pregunta es "no", esto ciertamente har la experiencia del partido de futbol de tu hijo muy diferente de lo que hubiera sido.
As que en cualquier lado donde miremos, cosas grandes y pequeas, cosas materiales y cosas del estilo de vida, la vida es una cuestin de elegir.
Y el mundo al que estabamos acostumbrados a vivir era as. Es decir, tenamos algunas elecciones, pero no todas era una cuestin de elegir,
Pero el mundo en el que vivimos ahora se ve as.
Y la pregunta es, son buenas o malas noticias?
La respuesta es s.
Todos sabemos lo bueno de esto, as que voy a hablar de lo malo.
Toda esto de elegir tiene dos efectos, dos efectos negativos en la gente.
Un efecto, paradjicamente, es que produce parlisis ms que liberacin.
Con tantas opciones a elegir, la gente encuentra simplemente difcil hacer la eleccin.
Les voy a dar un ejemplo drstico de esto, un estudio que se hizo de inversiones para planes de retiro voluntario.
Un colega mo tuvo acceso a los registros de inversin de Vanguard, el gigante de fondos de inversin de cerca de un milln de empleados en cerca de 2,000 diferentes lugares de trabajo.
Lo que ella encontr es que por cada 10 fondos de inversin que el patrn ofreca, la tasa de participacin bajaba dos por ciento.
Si se ofrecan 50 fondos, 10 por ciento menos de empleados participaban. que si slo se ofrecan cinco por qu?
Porque con 50 fondos a escoger, es tan difcil decidir cul fondo escoger. que simplemente lo pospones para maana.
Y entonces maana y maana y maana y maana, y por supuesto maana nunca llega.
Entendamos que esto no slo significa que la gente tendr que comer comida de perros cuando se retire porque no tendrn dinero suficiente para ahorrar tambin significa que tomar una decisin es tan difcil que dejan pasar una importante beneficio monetario de su empleador.
Al no participar, dejan pasar tanto como 5000 dlares al ao de su empleador, quien felizmente se beneficia.
As que la parlisis es una consecuencia de tener demasiadas elecciones.
Y pienso que esto hace que el mundo se vea as.
En verdad uno quiere tomar la decisin correcta si es por toda la eternidad cierto?
Uno no quiere elegir el fondo errneo, incluso el aderezo incorrecto.
Entonces este es un efecto. El segundo efecto es que aun cuando logremos rebasar la parlisis y elegir, acabamos menos satisfechos con el resultado de la eleccin de lo que estaramos si hubisemos tenido menor opciones para elegir.
Y hay varias razones para esto.
Entre ms opciones existan, es ms fcil lamentarlo todo, hace que la opcin que elegiste sea decepcionante.
Segundo, lo que los economistas llaman costos de oportunidad.
Dan Gilbert recalc esto esta maana al hablar de como la manera que valoramos las cosas varia de acuerdo a lo que las comparamos.
Bien, cuando existen muchas alternativas a considerar, es fcil imaginar los aspectos atractivos de las alternativas que rechazas, que te dejan menos satisfecho con la alternativa que has escogido.
Les pongo un ejemplo. Para aquellos de ustedes que no sean neoyorquinos, una disculpa.
Aqu est lo que se supone que ests pensando.
Tenemos una pareja en los Hamptons.
Una propiedad muy cara.
Playa fabulosa, da hermoso. Lo tienen todo para ellos.
Qu podra haber mejor? "Pues, maldita sea, "
est pensando este tipo, "Es agosto, todo mundo en el vecindario de Manhattan est fuera.
Podra estacionarme justo en frente de mi edificio."
Pasa dos semanas atormentado por la idea de que se est perdiendo la oportunidad, da tras da, de tener un buen lugar para estacionarse.
Los costos de oportunidad sustraen de la satisfaccin que obtenemos de lo que elegimos, incluso cuando lo que elegimos es estupendo.
Y entre ms opciones existan a considerar, ms aspectos atractivos de estas opciones se reflejarn en nosotros como costos de oportunidad.
Otro ejemplo.
Esta caricatura tiene varios puntos.
Hace tambin observaciones acerca de vivir en el momento, y probablemente sobre hacer las cosas despacio.
Pero un punto que hace es que en el momento en que elegimos una cosa, ests eligiendo no hacer otras cosas. Y esas otras cosas tienen muchos aspectos atractivos, que harn que lo que ests haciendo sea menos atractivo.
Tercero: escala de expectativas.
Me d cuenta de esto cuando fui a reemplazar unos jeans.
Visto jeans casi todo el tiempo.
Y hubo una poca en que los jeans eran de un solo tipo, y los comprabas, y te quedaban horrible, y eran increblemente incmodos, y si los vestas el tiempo suficiente y los lavabas las suficientes veces, empezaban a sentirse bien.
As que fui a reemplazar mis jeans despus de aos y aos de usar los viejos, y dije: "Quiero unos jeans de esta talla."
Y el vendedor de la tienda dice: "Los quiere ajustados, justos, o sueltos?
Los quiere con bragueta de botones o cierre? Deslavados a piedra o en cido?
Los quiere aflojados?
Los quiere de corte recto, estrecho, bla, bla bla..." y as se sigui.
Se me cay la quijada y cuando me recuper, le dije, "Quiero del tipo que sola ser el nico tipo que haba."
El vendedor no tena idea de lo que era, as que me pase una hora probando todos estos pantalones, y sal de la tienda -la verdad sea dicha- con el jean que mejor me ha quedado. Mejor. Toda esta eleccin me permiti mejorar.
Pero me sent peor.
Por qu? Escrib todo un libro para intentar explicrmelo a m mismo.
La razn por la que me sent peor es que, con todas estas opciones disponibles, mis expectativas acerca de un par de jeans se fueron para arriba.
Yo tena expectativas bajas. No tena expectativas particulares cuando slo haba un tipo.
Ahora que vienen en 100 diferentes, maldita sea, uno de ellos ha de ser perfecto.
Y lo que obtuve fue bueno, pero no fue perfecto.
As que compar lo que obtuve con lo que esperaba, y lo que obtuve fue decepcionante en comparacin a lo que esperaba.
Agregar opciones a la vida de la gente inevitablemente incrementa las expectativas que las personas tienen sobre lo bueno que esas opciones tienen.
Y lo que eso va a producir es menos satisfaccin con los resultados, aun cuando los resultados sean buenos.
Nadie en el mundo del marketing sabe esto
Porque si lo supieran, ustedes no sabran nada acerca de esto.
La verdad es ms parecida a esto.
La razn de que todo era mejor antes cuando todo era peor es que cuando todo era peor, era en efecto posible que gente tuviera experiencias que fuesen sorpresas placenteras.
En la actualidad, en el mundo en que vivimos, nosotros los ciudadanos industrializados, afluentes, con perfeccin de la expectativa, lo mejor que puedes aspirar es que las cosas sean tan buenas como esperabas que lo fueran.
Nunca recibirs una sorpresa placentera porque tus expectativas, mis expectativas, se fueran por arriba del techo.
El secreto de la felicidad -- que es lo que todos buscamos -- el secreto de la felicidad es tener bajas expectativas.
Quiero decirles -- un corto aporte autobiogrfico -- que estoy casado con una mujer que es realmente bastante maravillosa.
No me pudo haber ido mejor. No me acomode.
Aunque acomodarse no siempre es algo malo.
Finalmente, una consecuencia de comprar un mal par de pantalones de mezclilla cuando slo existe un tipo a comprar es que cuando ests insatisfecho y te preguntas por qu, quin es el responsable, la respuesta es clara.
El mundo es responsable qu puedes hacer?
Cuando existen cientos estilos diferentes de jeans disponibles, y compras uno que te decepciona, y te preguntas por qu, quin es el responsable?
Es de la igualmente claro que la respuesta a la pregunta eres t.
Pudiste haberlo hecho mejor.
Con un centenar de tipos diferentes de jeasn en despliegue, no hay excusa al fracaso.
Entonces cuando la gente toma decisiones, incluso cuando los resultados de las decisiones sean buenos, se sienten decepcionados por ellos, se culpan as mismos.
La depresin clnica ha explotado en el mundo industrial en la ltima generacin.
Yo creo que un contribuyente significativo, no el nico, pero significativo a esta explosin de la depresin al igual que del suicidio, es que la gente tiene experiencias que son decepcionantes porque sus estndares son muy altos. Y cuando tienen que explicarse estas experiencias a s mismos, piensan que son culpables.
Entonces el resultado neto es que en general lo estamos haciendo mejor, objetivamente, pero nos sentimos peor.
As que djenme que les recuerde.
Este es el dogma oficial, el que todos tomamos como verdadero, y que sea del todo falso. No es verdadero.
No cabe duda que algo de eleccion es mejor que nada, pero tener ms elecciones no es mejor que slo tener algunas cuantas
Existe un monto mgico. No s cul es;
pero me siento lo suficiente confiado para afirmar que hace mucho que rebasamos el punto donde esas opciones mejoraban nuestro bienestar.
Ahora, como una cuestin de polticas -- ya casi termino -- como una cuestin de polticas, la cosa a pensar es esta. Lo que permite toda estas elecciones en las sociedades industriales es la afluencia material.
Hay muchos lugares en el mundo, y hemos escuchado acerca de varios de ellos, donde su problema no es que tengan demasiadas opciones.
Su problema es que tienen demasiado pocas.
As que esto de lo que hablo es un problema peculiar de sociedades occidentales, afluentes, modernas.
Y lo que es frustrante y exasperante es esto: Steve Levitt nos habl ayer acerca de cmo no sirven estos asientos para nios caros y difciles de instalar. Es un desperdicio de dinero.
Lo que les estoy diciendo es que estas opciones complicadas y caras, no es simplemente que no sirvan,
de hecho lastiman.
Nos hacen sentir peor.
Si algo de lo que permite que la gente en nuestras sociedades tenga tantas opciones se trasladara a sociedades en que la gente tiene muy pocas opciones, no slo se mejorara la vida de esas personas, sino tambin la nuestra mejorara. Esto es lo que los economistas llaman ptimo de Pareto.
La redistribucin del ingreso nos beneficia a todos -- no slo a la gente pobre -- debido a cmo todo este exceso de opciones nos infestan.
Para concluir. Se supone que leyeron esta caricatura, y, siendo una persona sofisticada, digamos, "Oh!qu sabe este pez?
Bueno nada es posible en esta pecera."
Imaginacin pobre, visin miope del mundo, y esa es la forma en que lo le la primera vez.
Entre ms lo pienso, sin embargo, ms me acerco a la opinin de que este pez sabe algo.
Porque la verdad de las cosas es que si rompes esta pecera para que todo sea posible, no tienes libertad; tienes parlisis.
Si rompes esta pecera para que todo sea posible, reduces tu satisfaccin.
Incrementas la parlisis y disminuyes la satisfaccin.
Todos necesitamos una pecera.
Esta ciertamente es muy limitada quizs incluso para el pez, ciertamente para nosotros.
Pero la ausencia de alguna pecera metafrica es una receta para la miseria, y, yo sospecho, para el desastre.
Muchas gracias

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,57 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
CS224N 2018-19: Homework 4
model_embeddings.py: Embeddings for the NMT model
Pencheng Yin <pcyin@cs.cmu.edu>
Sahil Chopra <schopra8@stanford.edu>
Anand Dhoot <anandd@stanford.edu>
"""
import torch.nn as nn
class ModelEmbeddings(nn.Module):
"""
Class that converts input words to their embeddings.
"""
def __init__(self, embed_size, vocab):
"""
Init the Embedding layers.
@param embed_size (int): Embedding size (dimensionality)
@param vocab (Vocab): Vocabulary object containing src and tgt languages
See vocab.py for documentation.
"""
super(ModelEmbeddings, self).__init__()
self.embed_size = embed_size
# default values
self.source = None
self.target = None
src_pad_token_idx = vocab.src['<pad>']
tgt_pad_token_idx = vocab.tgt['<pad>']
### YOUR CODE HERE (~2 Lines)
### TODO - Initialize the following variables:
### self.source (Embedding Layer for source language)
### self.target (Embedding Layer for target langauge)
###
### Note:
### 1. `vocab` object contains two vocabularies:
### `vocab.src` for source
### `vocab.tgt` for target
### 2. You can get the length of a specific vocabulary by running:
### `len(vocab.<specific_vocabulary>)`
### 3. Remember to include the padding token for the specific vocabulary
### when creating your Embedding.
###
### Use the following docs to properly initialize these variables:
### Embedding Layer:
### https://pytorch.org/docs/stable/nn.html#torch.nn.Embedding
self.source = nn.Embedding(len(vocab.src),embed_size,src_pad_token_idx)
self.target = nn.Embedding(len(vocab.tgt),embed_size,tgt_pad_token_idx)
### END YOUR CODE

View File

@@ -0,0 +1,515 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
CS224N 2018-19: Homework 4
nmt_model.py: NMT Model
Pencheng Yin <pcyin@cs.cmu.edu>
Sahil Chopra <schopra8@stanford.edu>
"""
from collections import namedtuple
import sys
from typing import List, Tuple, Dict, Set, Union
import torch
import torch.nn as nn
import torch.nn.utils
import torch.nn.functional as F
from torch.nn.utils.rnn import pad_packed_sequence, pack_padded_sequence
from model_embeddings import ModelEmbeddings
Hypothesis = namedtuple('Hypothesis', ['value', 'score'])
class NMT(nn.Module):
""" Simple Neural Machine Translation Model:
- Bidrectional LSTM Encoder
- Unidirection LSTM Decoder
- Global Attention Model (Luong, et al. 2015)
"""
def __init__(self, embed_size, hidden_size, vocab, dropout_rate=0.2):
""" Init NMT Model.
@param embed_size (int): Embedding size (dimensionality)
@param hidden_size (int): Hidden Size (dimensionality)
@param vocab (Vocab): Vocabulary object containing src and tgt languages
See vocab.py for documentation.
@param dropout_rate (float): Dropout probability, for attention
"""
super(NMT, self).__init__()
self.model_embeddings = ModelEmbeddings(embed_size, vocab)
self.hidden_size = hidden_size
self.dropout_rate = dropout_rate
self.vocab = vocab
# default values
self.encoder = None
self.decoder = None
self.h_projection = None
self.c_projection = None
self.att_projection = None
self.combined_output_projection = None
self.target_vocab_projection = None
self.dropout = None
### YOUR CODE HERE (~8 Lines)
### TODO - Initialize the following variables:
### self.encoder (Bidirectional LSTM with bias)
### self.decoder (LSTM Cell with bias)
### self.h_projection (Linear Layer with no bias), called W_{h} in the PDF.
### self.c_projection (Linear Layer with no bias), called W_{c} in the PDF.
### self.att_projection (Linear Layer with no bias), called W_{attProj} in the PDF.
### self.combined_output_projection (Linear Layer with no bias), called W_{u} in the PDF.
### self.target_vocab_projection (Linear Layer with no bias), called W_{vocab} in the PDF.
### self.dropout (Dropout Layer)
###
### Use the following docs to properly initialize these variables:
### LSTM:
### https://pytorch.org/docs/stable/nn.html#torch.nn.LSTM
### LSTM Cell:
### https://pytorch.org/docs/stable/nn.html#torch.nn.LSTMCell
### Linear Layer:
### https://pytorch.org/docs/stable/nn.html#torch.nn.Linear
### Dropout Layer:
### https://pytorch.org/docs/stable/nn.html#torch.nn.Dropout
self.encoder = nn.LSTM(embed_size,hidden_size,num_layers=1,bias=True,bidirectional=True)
self.decoder = nn.LSTMCell(embed_size+hidden_size,hidden_size,bias=True)
self.h_projection = nn.Linear(hidden_size*2,hidden_size,bias=False)
self.c_projection = nn.Linear(hidden_size*2,hidden_size,bias=False)
self.att_projection = nn.Linear(hidden_size*2,hidden_size,bias=False)
self.combined_output_projection= nn.Linear(hidden_size*3,hidden_size,bias=False)
self.target_vocab_projection = nn.Linear(hidden_size,len(vocab.tgt),bias=False)
self.dropout = nn.Dropout(dropout_rate)
### END YOUR CODE
def forward(self, source: List[List[str]], target: List[List[str]]) -> torch.Tensor:
""" Take a mini-batch of source and target sentences, compute the log-likelihood of
target sentences under the language models learned by the NMT system.
@param source (List[List[str]]): list of source sentence tokens
@param target (List[List[str]]): list of target sentence tokens, wrapped by `<s>` and `</s>`
@returns scores (Tensor): a variable/tensor of shape (b, ) representing the
log-likelihood of generating the gold-standard target sentence for
each example in the input batch. Here b = batch size.
"""
# Compute sentence lengths
source_lengths = [len(s) for s in source]
# Convert list of lists into tensors
source_padded = self.vocab.src.to_input_tensor(source, device=self.device) # Tensor: (src_len, b)
target_padded = self.vocab.tgt.to_input_tensor(target, device=self.device) # Tensor: (tgt_len, b)
### Run the network forward:
### 1. Apply the encoder to `source_padded` by calling `self.encode()`
### 2. Generate sentence masks for `source_padded` by calling `self.generate_sent_masks()`
### 3. Apply the decoder to compute combined-output by calling `self.decode()`
### 4. Compute log probability distribution over the target vocabulary using the
### combined_outputs returned by the `self.decode()` function.
enc_hiddens, dec_init_state = self.encode(source_padded, source_lengths)
enc_masks = self.generate_sent_masks(enc_hiddens, source_lengths)
combined_outputs = self.decode(enc_hiddens, enc_masks, dec_init_state, target_padded)#[target_len,b,e]
P = F.log_softmax(self.target_vocab_projection(combined_outputs), dim=-1)#[target_len,b,V]
# Zero out, probabilities for which we have nothing in the target text
target_masks = (target_padded != self.vocab.tgt['<pad>']).float()
# Compute log probability of generating true target words
target_gold_words_log_prob = torch.gather(P, index=target_padded[1:].unsqueeze(-1), dim=-1).squeeze(-1) * target_masks[1:]
scores = target_gold_words_log_prob.sum(dim=0)
return scores
def encode(self, source_padded: torch.Tensor, source_lengths: List[int]) -> Tuple[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]:
""" Apply the encoder to source sentences to obtain encoder hidden states.
Additionally, take the final states of the encoder and project them to obtain initial states for decoder.
@param source_padded (Tensor): Tensor of padded source sentences with shape (b, src_len), where
b = batch_size, src_len = maximum source sentence length. Note that
these have already been sorted in order of longest to shortest sentence.
@param source_lengths (List[int]): List of actual lengths for each of the source sentences in the batch
@returns enc_hiddens (Tensor): Tensor of hidden units with shape (b, src_len, h*2), where
b = batch size, src_len = maximum source sentence length, h = hidden size.
@returns dec_init_state (tuple(Tensor, Tensor)): Tuple of tensors representing the decoder's initial
hidden state and cell.
"""
enc_hiddens, dec_init_state = None, None
### YOUR CODE HERE (~ 8 Lines)
### TODO:
### 1. Construct Tensor `X` of source sentences with shape (src_len, b, e) using the source model embeddings.
### src_len = maximum source sentence length, b = batch size, e = embedding size. Note
### that there is no initial hidden state or cell for the decoder.
### 2. Compute `enc_hiddens`, `last_hidden`, `last_cell` by applying the encoder to `X`.
### - Before you can apply the encoder, you need to apply the `pack_padded_sequence` function to X.
### - After you apply the encoder, you need to apply the `pad_packed_sequence` function to enc_hiddens.
### - Note that the shape of the tensor returned by the encoder is (src_len b, h*2) and we want to
### return a tensor of shape (b, src_len, h*2) as `enc_hiddens`.
### 3. Compute `dec_init_state` = (init_decoder_hidden, init_decoder_cell):
### - `init_decoder_hidden`:
### `last_hidden` is a tensor shape (2, b, h). The first dimension corresponds to forwards and backwards.
### Concatenate the forwards and backwards tensors to obtain a tensor shape (b, 2*h).
### Apply the h_projection layer to this in order to compute init_decoder_hidden.
### This is h_0^{dec} in the PDF. Here b = batch size, h = hidden size
### - `init_decoder_cell`:
### `last_cell` is a tensor shape (2, b, h). The first dimension corresponds to forwards and backwards.
### Concatenate the forwards and backwards tensors to obtain a tensor shape (b, 2*h).
### Apply the c_projection layer to this in order to compute init_decoder_cell.
### This is c_0^{dec} in the PDF. Here b = batch size, h = hidden size
###
### See the following docs, as you may need to use some of the following functions in your implementation:
### Pack the padded sequence X before passing to the encoder:
### https://pytorch.org/docs/stable/nn.html#torch.nn.utils.rnn.pack_padded_sequence
### Pad the packed sequence, enc_hiddens, returned by the encoder:
### https://pytorch.org/docs/stable/nn.html#torch.nn.utils.rnn.pad_packed_sequence
### Tensor Concatenation:
### https://pytorch.org/docs/stable/torch.html#torch.cat
### Tensor Permute:
### https://pytorch.org/docs/stable/tensors.html#torch.Tensor.permute
src_padded_embedding= F.embedding(source_padded, self.model_embeddings.source.weight)#(src_len, b, e)
X = nn.utils.rnn.pack_padded_sequence(src_padded_embedding,source_lengths)
enc_hiddens,(last_hidden,last_cell) = self.encoder(X)
enc_hiddens = nn.utils.rnn.pad_packed_sequence(enc_hiddens,batch_first=True,total_length=source_padded.size(0))#,padding_value='<pad>')
enc_hiddens = enc_hiddens[0]#(b, src_len, hidden_size*2)
dec_init_state_h = torch.cat((last_hidden[0],last_hidden[1]),1)#(b, hidden_size*2)
init_decoder_hidden = self.h_projection(dec_init_state_h)#(b, hidden_size)
dec_init_state_c = torch.cat((last_cell[0],last_cell[1]),1)
init_decoder_cell = self.c_projection(dec_init_state_c)
dec_init_state = (init_decoder_hidden,init_decoder_cell)
### END YOUR CODE
return enc_hiddens, dec_init_state
def decode(self, enc_hiddens: torch.Tensor, enc_masks: torch.Tensor,
dec_init_state: Tuple[torch.Tensor, torch.Tensor], target_padded: torch.Tensor) -> torch.Tensor:
"""Compute combined output vectors for a batch.
@param enc_hiddens (Tensor): Hidden states (b, src_len, h*2), where
b = batch size, src_len = maximum source sentence length, h = hidden size.
@param enc_masks (Tensor): Tensor of sentence masks (b, src_len), where
b = batch size, src_len = maximum source sentence length.
@param dec_init_state (tuple(Tensor, Tensor)): Initial state and cell for decoder
@param target_padded (Tensor): Gold-standard padded target sentences (tgt_len, b), where
tgt_len = maximum target sentence length, b = batch size.
@returns combined_outputs (Tensor): combined output tensor (tgt_len, b, h), where
tgt_len = maximum target sentence length, b = batch_size, h = hidden size
"""
# Chop of the <END> token for max length sentences.
target_padded = target_padded[:-1]
# Initialize the decoder state (hidden and cell)
dec_state = dec_init_state
# Initialize previous combined output vector o_{t-1} as zero
batch_size = enc_hiddens.size(0)
o_prev = torch.zeros(batch_size, self.hidden_size, device=self.device)
# Initialize a list we will use to collect the combined output o_t on each step
combined_outputs = []
### YOUR CODE HERE (~9 Lines)
### TODO:
### 1. Apply the attention projection layer to `enc_hiddens` to obtain `enc_hiddens_proj`,
### which should be shape (b, src_len, h),
### where b = batch size, src_len = maximum source length, h = hidden size.
### This is applying W_{attProj} to h^enc, as described in the PDF.
### 2. Construct tensor `Y` of target sentences with shape (tgt_len, b, e) using the target model embeddings.
### where tgt_len = maximum target sentence length, b = batch size, e = embedding size.
### 3. Use the torch.split function to iterate over the time dimension of Y.
### Within the loop, this will give you Y_t of shape (1, b, e) where b = batch size, e = embedding size.
### - Squeeze Y_t into a tensor of dimension (b, e).
### - Construct Ybar_t by concatenating Y_t with o_prev.
### - Use the step function to compute the the Decoder's next (cell, state) values
### as well as the new combined output o_t.
### - Append o_t to combined_outputs
### - Update o_prev to the new o_t.
### 4. Use torch.stack to convert combined_outputs from a list length tgt_len of
### tensors shape (b, h), to a single tensor shape (tgt_len, b, h)
### where tgt_len = maximum target sentence length, b = batch size, h = hidden size.
###
### Note:
### - When using the squeeze() function make sure to specify the dimension you want to squeeze
### over. Otherwise, you will remove the batch dimension accidentally, if batch_size = 1.
###
### Use the following docs to implement this functionality:
### Zeros Tensor:
### https://pytorch.org/docs/stable/torch.html#torch.zeros
### Tensor Splitting (iteration):
### https://pytorch.org/docs/stable/torch.html#torch.split
### Tensor Dimension Squeezing:
### https://pytorch.org/docs/stable/torch.html#torch.squeeze
### Tensor Concatenation:
### https://pytorch.org/docs/stable/torch.html#torch.cat
### Tensor Stacking:
### https://pytorch.org/docs/stable/torch.html#torch.stack
enc_hiddens_proj = self.att_projection(enc_hiddens)#[b,src_len,h]
tgt_padded_embedding= F.embedding(target_padded, self.model_embeddings.target.weight)
Y = tgt_padded_embedding
looper = torch.split(Y,1,0)
for slice in looper:
Y_t = torch.squeeze(slice,dim=0)#1,b,e->b,e
Ybar_t = torch.cat((Y_t,o_prev),1)#[b,e]+[b,e]->[b,2e]
dec_state, o_t, e_t = self.step(Ybar_t,dec_state,enc_hiddens,enc_hiddens_proj,enc_masks)
combined_outputs.append(o_t)
o_prev = o_t
combined_outputs = torch.stack(combined_outputs,dim=0)
### END YOUR CODE
return combined_outputs#[t_len,b,e]
def step(self, Ybar_t: torch.Tensor,
dec_state: Tuple[torch.Tensor, torch.Tensor],
enc_hiddens: torch.Tensor,
enc_hiddens_proj: torch.Tensor,
enc_masks: torch.Tensor) -> Tuple[Tuple, torch.Tensor, torch.Tensor]:
""" Compute one forward step of the LSTM decoder, including the attention computation.
@param Ybar_t (Tensor): Concatenated Tensor of [Y_t o_prev], with shape (b, e + h). The input for the decoder,
where b = batch size, e = embedding size, h = hidden size.
@param dec_state (tuple(Tensor, Tensor)): Tuple of tensors both with shape (b, h), where b = batch size, h = hidden size.
First tensor is decoder's prev hidden state, second tensor is decoder's prev cell.
@param enc_hiddens (Tensor): Encoder hidden states Tensor, with shape (b, src_len, h * 2), where b = batch size,
src_len = maximum source length, h = hidden size.
@param enc_hiddens_proj (Tensor): Encoder hidden states Tensor, projected from (h * 2) to h. Tensor is with shape (b, src_len, h),
where b = batch size, src_len = maximum source length, h = hidden size.
@param enc_masks (Tensor): Tensor of sentence masks shape (b, src_len),
where b = batch size, src_len is maximum source length.
@returns dec_state (tuple (Tensor, Tensor)): Tuple of tensors both shape (b, h), where b = batch size, h = hidden size.
First tensor is decoder's new hidden state, second tensor is decoder's new cell.
@returns combined_output (Tensor): Combined output Tensor at timestep t, shape (b, h), where b = batch size, h = hidden size.
@returns e_t (Tensor): Tensor of shape (b, src_len). It is attention scores distribution.
Note: You will not use this outside of this function.
We are simply returning this value so that we can sanity check
your implementation.
"""
combined_output = None
### YOUR CODE HERE (~3 Lines)
### TODO:
### 1. Apply the decoder to `Ybar_t` and `dec_state`to obtain the new dec_state.
### 2. Split dec_state into its two parts (dec_hidden, dec_cell)
### 3. Compute the attention scores e_t, a Tensor shape (b, src_len).
### Note: b = batch_size, src_len = maximum source length, h = hidden size.
###
### Hints:
### - dec_hidden is shape (b, h) and corresponds to h^dec_t in the PDF (batched)
### - enc_hiddens_proj is shape (b, src_len, h) and corresponds to W_{attProj} h^enc (batched).
### - Use batched matrix multiplication (torch.bmm) to compute e_t.
### - To get the tensors into the right shapes for bmm, you will need to do some squeezing and unsqueezing.
### - When using the squeeze() function make sure to specify the dimension you want to squeeze
### over. Otherwise, you will remove the batch dimension accidentally, if batch_size = 1.
###
### Use the following docs to implement this functionality:
### Batch Multiplication:
### https://pytorch.org/docs/stable/torch.html#torch.bmm
### Tensor Unsqueeze:
### https://pytorch.org/docs/stable/torch.html#torch.unsqueeze
### Tensor Squeeze:
### https://pytorch.org/docs/stable/torch.html#torch.squeeze
dec_hidden,dec_cell = self.decoder(Ybar_t,dec_state) #Ybar_t [b,2e] dec_state h[b,e],c[b,e] dec_hidden [b,e] dec_cell [b,e]
dec_state = (dec_hidden,dec_cell)
dec_hidden_uns = torch.unsqueeze(dec_hidden,2) #[b,e,1]
e_t = torch.bmm(enc_hiddens_proj,dec_hidden_uns)# [b,src_len,e] mul [b,e,1] 对存储在两个批batch1和batch2内的矩阵进行批矩阵乘操作
e_t=torch.squeeze(e_t,dim=2)# [b,src_len,1]->[b,src_len]
### END YOUR CODE
# Set e_t to -inf where enc_masks has 1
if enc_masks is not None:
e_t.data.masked_fill_(enc_masks.byte(), -float('inf'))
### YOUR CODE HERE (~6 Lines)
### TODO:
### 1. Apply softmax to e_t to yield alpha_t
### 2. Use batched matrix multiplication between alpha_t and enc_hiddens to obtain the
### attention output vector, a_t.
#$$ Hints:
### - alpha_t is shape (b, src_len)
### - enc_hiddens is shape (b, src_len, 2h)
### - a_t should be shape (b, 2h)
### - You will need to do some squeezing and unsqueezing.
### Note: b = batch size, src_len = maximum source length, h = hidden size.
###
### 3. Concatenate dec_hidden with a_t to compute tensor U_t
### 4. Apply the combined output projection layer to U_t to compute tensor V_t
### 5. Compute tensor O_t by first applying the Tanh function and then the dropout layer.
###
### Use the following docs to implement this functionality:
### Softmax:
### https://pytorch.org/docs/stable/nn.html#torch.nn.functional.softmax
### Batch Multiplication:
### https://pytorch.org/docs/stable/torch.html#torch.bmm
### Tensor View:
### https://pytorch.org/docs/stable/tensors.html#torch.Tensor.view
### Tensor Concatenation:
### https://pytorch.org/docs/stable/torch.html#torch.cat
### Tanh:
### https://pytorch.org/docs/stable/torch.html#torch.tanh
alpha_t = torch.nn.functional.softmax(e_t,dim=1)#[b,src_len]
alpha_t_uns = torch.unsqueeze(alpha_t,1)#[b,1,src_len]
a_t = torch.bmm(alpha_t_uns,enc_hiddens)#[b,1,src_len] mul b,src_len,2e] ->[b,1,2e]
a_t = torch.squeeze(a_t,1)#[b,1,2e]->[b,2e]
U_t = torch.cat((dec_hidden,a_t),1)#[b,e] cat [b,2e] -> [b,3e]
V_t = self.combined_output_projection(U_t)#[b,3e]->[b,e]
tanh_V_t = torch.tanh(V_t)#[b,e]
O_t = self.dropout(tanh_V_t)#[b,e]
### END YOUR CODE
combined_output = O_t
return dec_state, combined_output, e_t
def generate_sent_masks(self, enc_hiddens: torch.Tensor, source_lengths: List[int]) -> torch.Tensor:
""" Generate sentence masks for encoder hidden states.
@param enc_hiddens (Tensor): encodings of shape (b, src_len, 2*h), where b = batch size,
src_len = max source length, h = hidden size.
@param source_lengths (List[int]): List of actual lengths for each of the sentences in the batch.
@returns enc_masks (Tensor): Tensor of sentence masks of shape (b, src_len),
where src_len = max source length, h = hidden size.
"""
enc_masks = torch.zeros(enc_hiddens.size(0), enc_hiddens.size(1), dtype=torch.float)
for e_id, src_len in enumerate(source_lengths):
enc_masks[e_id, src_len:] = 1
return enc_masks.to(self.device)
def beam_search(self, src_sent: List[str], beam_size: int=5, max_decoding_time_step: int=70) -> List[Hypothesis]:
""" Given a single source sentence, perform beam search, yielding translations in the target language.
@param src_sent (List[str]): a single source sentence (words)
@param beam_size (int): beam size
@param max_decoding_time_step (int): maximum number of time steps to unroll the decoding RNN
@returns hypotheses (List[Hypothesis]): a list of hypothesis, each hypothesis has two fields:
value: List[str]: the decoded target sentence, represented as a list of words
score: float: the log-likelihood of the target sentence
"""
src_sents_var = self.vocab.src.to_input_tensor([src_sent], self.device)
src_encodings, dec_init_vec = self.encode(src_sents_var, [len(src_sent)])
src_encodings_att_linear = self.att_projection(src_encodings)
h_tm1 = dec_init_vec
att_tm1 = torch.zeros(1, self.hidden_size, device=self.device)
eos_id = self.vocab.tgt['</s>']
hypotheses = [['<s>']]
hyp_scores = torch.zeros(len(hypotheses), dtype=torch.float, device=self.device)
completed_hypotheses = []
t = 0
while len(completed_hypotheses) < beam_size and t < max_decoding_time_step:
t += 1
hyp_num = len(hypotheses)
exp_src_encodings = src_encodings.expand(hyp_num,
src_encodings.size(1),
src_encodings.size(2))
exp_src_encodings_att_linear = src_encodings_att_linear.expand(hyp_num,
src_encodings_att_linear.size(1),
src_encodings_att_linear.size(2))
y_tm1 = torch.tensor([self.vocab.tgt[hyp[-1]] for hyp in hypotheses], dtype=torch.long, device=self.device)
y_t_embed = self.model_embeddings.target(y_tm1)
x = torch.cat([y_t_embed, att_tm1], dim=-1)
(h_t, cell_t), att_t, _ = self.step(x, h_tm1,
exp_src_encodings, exp_src_encodings_att_linear, enc_masks=None)
# log probabilities over target words
log_p_t = F.log_softmax(self.target_vocab_projection(att_t), dim=-1)
live_hyp_num = beam_size - len(completed_hypotheses)
contiuating_hyp_scores = (hyp_scores.unsqueeze(1).expand_as(log_p_t) + log_p_t).view(-1)
top_cand_hyp_scores, top_cand_hyp_pos = torch.topk(contiuating_hyp_scores, k=live_hyp_num)
prev_hyp_ids = top_cand_hyp_pos / len(self.vocab.tgt)
hyp_word_ids = top_cand_hyp_pos % len(self.vocab.tgt)
new_hypotheses = []
live_hyp_ids = []
new_hyp_scores = []
for prev_hyp_id, hyp_word_id, cand_new_hyp_score in zip(prev_hyp_ids, hyp_word_ids, top_cand_hyp_scores):
prev_hyp_id = prev_hyp_id.item()
hyp_word_id = hyp_word_id.item()
cand_new_hyp_score = cand_new_hyp_score.item()
hyp_word = self.vocab.tgt.id2word[hyp_word_id]
new_hyp_sent = hypotheses[prev_hyp_id] + [hyp_word]
if hyp_word == '</s>':
completed_hypotheses.append(Hypothesis(value=new_hyp_sent[1:-1],
score=cand_new_hyp_score))
else:
new_hypotheses.append(new_hyp_sent)
live_hyp_ids.append(prev_hyp_id)
new_hyp_scores.append(cand_new_hyp_score)
if len(completed_hypotheses) == beam_size:
break
live_hyp_ids = torch.tensor(live_hyp_ids, dtype=torch.long, device=self.device)
h_tm1 = (h_t[live_hyp_ids], cell_t[live_hyp_ids])
att_tm1 = att_t[live_hyp_ids]
hypotheses = new_hypotheses
hyp_scores = torch.tensor(new_hyp_scores, dtype=torch.float, device=self.device)
if len(completed_hypotheses) == 0:
completed_hypotheses.append(Hypothesis(value=hypotheses[0][1:],
score=hyp_scores[0].item()))
completed_hypotheses.sort(key=lambda hyp: hyp.score, reverse=True)
return completed_hypotheses
@property
def device(self) -> torch.device:
""" Determine which device to place the Tensors upon, CPU or GPU.
"""
return self.model_embeddings.source.weight.device
@staticmethod
def load(model_path: str):
""" Load the model from a file.
@param model_path (str): path to model
"""
params = torch.load(model_path, map_location=lambda storage, loc: storage)
args = params['args']
model = NMT(vocab=params['vocab'], **args)
model.load_state_dict(params['state_dict'])
return model
def save(self, path: str):
""" Save the odel to a file.
@param path (str): path to the model
"""
print('save model parameters to [%s]' % path, file=sys.stderr)
params = {
'args': dict(embed_size=self.model_embeddings.embed_size, hidden_size=self.hidden_size, dropout_rate=self.dropout_rate),
'vocab': self.vocab,
'state_dict': self.state_dict()
}
torch.save(params, path)

View File

@@ -0,0 +1,343 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
CS224N 2018-19: Homework 4
run.py: Run Script for Simple NMT Model
Pencheng Yin <pcyin@cs.cmu.edu>
Sahil Chopra <schopra8@stanford.edu>
Usage:
run.py train --train-src=<file> --train-tgt=<file> --dev-src=<file> --dev-tgt=<file> --vocab=<file> [options]
run.py decode [options] MODEL_PATH TEST_SOURCE_FILE OUTPUT_FILE
run.py decode [options] MODEL_PATH TEST_SOURCE_FILE TEST_TARGET_FILE OUTPUT_FILE
Options:
-h --help show this screen.
--cuda use GPU
--train-src=<file> train source file
--train-tgt=<file> train target file
--dev-src=<file> dev source file
--dev-tgt=<file> dev target file
--vocab=<file> vocab file
--seed=<int> seed [default: 0]
--batch-size=<int> batch size [default: 32]
--embed-size=<int> embedding size [default: 256]
--hidden-size=<int> hidden size [default: 256]
--clip-grad=<float> gradient clipping [default: 5.0]
--log-every=<int> log every [default: 10]
--max-epoch=<int> max epoch [default: 30]
--input-feed use input feeding
--patience=<int> wait for how many iterations to decay learning rate [default: 5]
--max-num-trial=<int> terminate training after how many trials [default: 5]
--lr-decay=<float> learning rate decay [default: 0.5]
--beam-size=<int> beam size [default: 5]
--sample-size=<int> sample size [default: 5]
--lr=<float> learning rate [default: 0.001]
--uniform-init=<float> uniformly initialize all parameters [default: 0.1]
--save-to=<file> model save path [default: model.bin]
--valid-niter=<int> perform validation after how many iterations [default: 2000]
--dropout=<float> dropout [default: 0.3]
--max-decoding-time-step=<int> maximum number of decoding time steps [default: 70]
"""
import math
import sys
import pickle
import time
from docopt import docopt
from nltk.translate.bleu_score import corpus_bleu, sentence_bleu, SmoothingFunction
from nmt_model import Hypothesis, NMT
import numpy as np
from typing import List, Tuple, Dict, Set, Union
from tqdm import tqdm
from utils import read_corpus, batch_iter
from vocab import Vocab, VocabEntry
import torch
import torch.nn.utils
def evaluate_ppl(model, dev_data, batch_size=32):
""" Evaluate perplexity on dev sentences
@param model (NMT): NMT Model
@param dev_data (list of (src_sent, tgt_sent)): list of tuples containing source and target sentence
@param batch_size (batch size)
@returns ppl (perplixty on dev sentences)
"""
was_training = model.training
model.eval()
cum_loss = 0.
cum_tgt_words = 0.
# no_grad() signals backend to throw away all gradients
with torch.no_grad():
for src_sents, tgt_sents in batch_iter(dev_data, batch_size):
loss = -model(src_sents, tgt_sents).sum()
cum_loss += loss.item()
tgt_word_num_to_predict = sum(len(s[1:]) for s in tgt_sents) # omitting leading `<s>`
cum_tgt_words += tgt_word_num_to_predict
ppl = np.exp(cum_loss / cum_tgt_words)
if was_training:
model.train()
return ppl
def compute_corpus_level_bleu_score(references: List[List[str]], hypotheses: List[Hypothesis]) -> float:
""" Given decoding results and reference sentences, compute corpus-level BLEU score.
@param references (List[List[str]]): a list of gold-standard reference target sentences
@param hypotheses (List[Hypothesis]): a list of hypotheses, one for each reference
@returns bleu_score: corpus-level BLEU score
"""
if references[0][0] == '<s>':
references = [ref[1:-1] for ref in references]
bleu_score = corpus_bleu([[ref] for ref in references],
[hyp.value for hyp in hypotheses])
return bleu_score
def train(args: Dict):
""" Train the NMT Model.
@param args (Dict): args from cmd line
"""
train_data_src = read_corpus(args['--train-src'], source='src')
train_data_tgt = read_corpus(args['--train-tgt'], source='tgt')
dev_data_src = read_corpus(args['--dev-src'], source='src')
dev_data_tgt = read_corpus(args['--dev-tgt'], source='tgt')
train_data = list(zip(train_data_src, train_data_tgt))
dev_data = list(zip(dev_data_src, dev_data_tgt))
train_batch_size = int(args['--batch-size'])
clip_grad = float(args['--clip-grad'])
valid_niter = int(args['--valid-niter'])
log_every = int(args['--log-every'])
model_save_path = args['--save-to']
vocab = Vocab.load(args['--vocab'])
model = NMT(embed_size=int(args['--embed-size']),
hidden_size=int(args['--hidden-size']),
dropout_rate=float(args['--dropout']),
vocab=vocab)
model.train()
uniform_init = float(args['--uniform-init'])
if np.abs(uniform_init) > 0.:
print('uniformly initialize parameters [-%f, +%f]' % (uniform_init, uniform_init), file=sys.stderr)
for p in model.parameters():
p.data.uniform_(-uniform_init, uniform_init)
vocab_mask = torch.ones(len(vocab.tgt))
vocab_mask[vocab.tgt['<pad>']] = 0
device = torch.device("cuda:0" if args['--cuda'] else "cpu")
print('use device: %s' % device, file=sys.stderr)
model = model.to(device)
optimizer = torch.optim.Adam(model.parameters(), lr=float(args['--lr']))
num_trial = 0
train_iter = patience = cum_loss = report_loss = cum_tgt_words = report_tgt_words = 0
cum_examples = report_examples = epoch = valid_num = 0
hist_valid_scores = []
train_time = begin_time = time.time()
print('begin Maximum Likelihood training')
while True:
epoch += 1
for src_sents, tgt_sents in batch_iter(train_data, batch_size=train_batch_size, shuffle=True):
train_iter += 1
optimizer.zero_grad()
batch_size = len(src_sents)
example_losses = -model(src_sents, tgt_sents) # (batch_size,)
batch_loss = example_losses.sum()
loss = batch_loss / batch_size
loss.backward()
# clip gradient
grad_norm = torch.nn.utils.clip_grad_norm_(model.parameters(), clip_grad)
optimizer.step()
batch_losses_val = batch_loss.item()
report_loss += batch_losses_val
cum_loss += batch_losses_val
tgt_words_num_to_predict = sum(len(s[1:]) for s in tgt_sents) # omitting leading `<s>`
report_tgt_words += tgt_words_num_to_predict
cum_tgt_words += tgt_words_num_to_predict
report_examples += batch_size
cum_examples += batch_size
if train_iter % log_every == 0:
print('epoch %d, iter %d, avg. loss %.2f, avg. ppl %.2f ' \
'cum. examples %d, speed %.2f words/sec, time elapsed %.2f sec' % (epoch, train_iter,
report_loss / report_examples,
math.exp(report_loss / report_tgt_words),
cum_examples,
report_tgt_words / (time.time() - train_time),
time.time() - begin_time), file=sys.stderr)
train_time = time.time()
report_loss = report_tgt_words = report_examples = 0.
# perform validation
if train_iter % valid_niter == 0:
print('epoch %d, iter %d, cum. loss %.2f, cum. ppl %.2f cum. examples %d' % (epoch, train_iter,
cum_loss / cum_examples,
np.exp(cum_loss / cum_tgt_words),
cum_examples), file=sys.stderr)
cum_loss = cum_examples = cum_tgt_words = 0.
valid_num += 1
print('begin validation ...', file=sys.stderr)
# compute dev. ppl and bleu
dev_ppl = evaluate_ppl(model, dev_data, batch_size=128) # dev batch size can be a bit larger
valid_metric = -dev_ppl
print('validation: iter %d, dev. ppl %f' % (train_iter, dev_ppl), file=sys.stderr)
is_better = len(hist_valid_scores) == 0 or valid_metric > max(hist_valid_scores)
hist_valid_scores.append(valid_metric)
if is_better:
patience = 0
print('save currently the best model to [%s]' % model_save_path, file=sys.stderr)
model.save(model_save_path)
# also save the optimizers' state
torch.save(optimizer.state_dict(), model_save_path + '.optim')
elif patience < int(args['--patience']):
patience += 1
print('hit patience %d' % patience, file=sys.stderr)
if patience == int(args['--patience']):
num_trial += 1
print('hit #%d trial' % num_trial, file=sys.stderr)
if num_trial == int(args['--max-num-trial']):
print('early stop!', file=sys.stderr)
exit(0)
# decay lr, and restore from previously best checkpoint
lr = optimizer.param_groups[0]['lr'] * float(args['--lr-decay'])
print('load previously best model and decay learning rate to %f' % lr, file=sys.stderr)
# load model
params = torch.load(model_save_path, map_location=lambda storage, loc: storage)
model.load_state_dict(params['state_dict'])
model = model.to(device)
print('restore parameters of the optimizers', file=sys.stderr)
optimizer.load_state_dict(torch.load(model_save_path + '.optim'))
# set new lr
for param_group in optimizer.param_groups:
param_group['lr'] = lr
# reset patience
patience = 0
if epoch == int(args['--max-epoch']):
print('reached maximum number of epochs!', file=sys.stderr)
exit(0)
def decode(args: Dict[str, str]):
""" Performs decoding on a test set, and save the best-scoring decoding results.
If the target gold-standard sentences are given, the function also computes
corpus-level BLEU score.
@param args (Dict): args from cmd line
"""
print("load test source sentences from [{}]".format(args['TEST_SOURCE_FILE']), file=sys.stderr)
test_data_src = read_corpus(args['TEST_SOURCE_FILE'], source='src')
if args['TEST_TARGET_FILE']:
print("load test target sentences from [{}]".format(args['TEST_TARGET_FILE']), file=sys.stderr)
test_data_tgt = read_corpus(args['TEST_TARGET_FILE'], source='tgt')
print("load model from {}".format(args['MODEL_PATH']), file=sys.stderr)
model = NMT.load(args['MODEL_PATH'])
if args['--cuda']:
model = model.to(torch.device("cuda:0"))
hypotheses = beam_search(model, test_data_src,
beam_size=int(args['--beam-size']),
max_decoding_time_step=int(args['--max-decoding-time-step']))
if args['TEST_TARGET_FILE']:
top_hypotheses = [hyps[0] for hyps in hypotheses]
bleu_score = compute_corpus_level_bleu_score(test_data_tgt, top_hypotheses)
print('Corpus BLEU: {}'.format(bleu_score * 100), file=sys.stderr)
with open(args['OUTPUT_FILE'], 'w') as f:
for src_sent, hyps in zip(test_data_src, hypotheses):
top_hyp = hyps[0]
hyp_sent = ' '.join(top_hyp.value)
f.write(hyp_sent + '\n')
def beam_search(model: NMT, test_data_src: List[List[str]], beam_size: int, max_decoding_time_step: int) -> List[List[Hypothesis]]:
""" Run beam search to construct hypotheses for a list of src-language sentences.
@param model (NMT): NMT Model
@param test_data_src (List[List[str]]): List of sentences (words) in source language, from test set.
@param beam_size (int): beam_size (# of hypotheses to hold for a translation at every step)
@param max_decoding_time_step (int): maximum sentence length that Beam search can produce
@returns hypotheses (List[List[Hypothesis]]): List of Hypothesis translations for every source sentence.
"""
was_training = model.training
model.eval()
hypotheses = []
with torch.no_grad():
for src_sent in tqdm(test_data_src, desc='Decoding', file=sys.stdout):
example_hyps = model.beam_search(src_sent, beam_size=beam_size, max_decoding_time_step=max_decoding_time_step)
hypotheses.append(example_hyps)
if was_training: model.train(was_training)
return hypotheses
def main():
""" Main func.
"""
args = docopt(__doc__)
# Check pytorch version
assert(torch.__version__ >= "1.0.0"), "Please update your installation of PyTorch. You have {} and you should have version 1.0.0".format(torch.__version__)
# seed the random number generators
seed = int(args['--seed'])
torch.manual_seed(seed)
if args['--cuda']:
torch.cuda.manual_seed(seed)
np.random.seed(seed * 13 // 7)
if args['train']:
train(args)
elif args['decode']:
decode(args)
else:
raise RuntimeError('invalid run mode')
if __name__ == '__main__':
main()

View File

@@ -0,0 +1,15 @@
#!/bin/bash
if [ "$1" = "train" ]; then
CUDA_VISIBLE_DEVICES=0 python run.py train --train-src=./en_es_data/train.es --train-tgt=./en_es_data/train.en --dev-src=./en_es_data/dev.es --dev-tgt=./en_es_data/dev.en --vocab=vocab.json --cuda
elif [ "$1" = "test" ]; then
CUDA_VISIBLE_DEVICES=0 python run.py decode model.bin ./en_es_data/test.es ./en_es_data/test.en outputs/test_outputs.txt --cuda
elif [ "$1" = "train_local" ]; then
python run.py train --train-src=./en_es_data/train.es --train-tgt=./en_es_data/train.en --dev-src=./en_es_data/dev.es --dev-tgt=./en_es_data/dev.en --vocab=vocab.json
elif [ "$1" = "test_local" ]; then
python run.py decode model.bin ./en_es_data/test.es ./en_es_data/test.en outputs/test_outputs.txt
elif [ "$1" = "vocab" ]; then
python vocab.py --train-src=./en_es_data/train.es --train-tgt=./en_es_data/train.en vocab.json
else
echo "Invalid Option Selected"
fi

View File

@@ -0,0 +1,236 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
CS224N 2018-19: Homework 4
sanity_check.py: sanity checks for assignment 4
Sahil Chopra <schopra8@stanford.edu>
Michael Hahn <>
Usage:
sanity_check.py 1d
sanity_check.py 1e
sanity_check.py 1f
"""
import math
import sys
import pickle
import time
import numpy as np
from docopt import docopt
from typing import List, Tuple, Dict, Set, Union
from tqdm import tqdm
from utils import read_corpus, batch_iter
from vocab import Vocab, VocabEntry
from nmt_model import NMT
import torch
import torch.nn as nn
import torch.nn.utils
#----------
# CONSTANTS
#----------
BATCH_SIZE = 5
EMBED_SIZE = 3
HIDDEN_SIZE = 3
DROPOUT_RATE = 0.0
def reinitialize_layers(model):
""" Reinitialize the Layer Weights for Sanity Checks.
"""
def init_weights(m):
if type(m) == nn.Linear:
m.weight.data.fill_(0.3)
if m.bias is not None:
m.bias.data.fill_(0.1)
elif type(m) == nn.Embedding:
m.weight.data.fill_(0.15)
elif type(m) == nn.Dropout:
nn.Dropout(DROPOUT_RATE)
with torch.no_grad():
model.apply(init_weights)
def generate_outputs(model, source, target, vocab):
""" Generate outputs.
"""
print ("-"*80)
print("Generating Comparison Outputs")
reinitialize_layers(model)
# Compute sentence lengths
source_lengths = [len(s) for s in source]
# Convert list of lists into tensors
source_padded = model.vocab.src.to_input_tensor(source, device=model.device)
target_padded = model.vocab.tgt.to_input_tensor(target, device=model.device)
# Run the model forward
with torch.no_grad():
enc_hiddens, dec_init_state = model.encode(source_padded, source_lengths)
enc_masks = model.generate_sent_masks(enc_hiddens, source_lengths)
combined_outputs = model.decode(enc_hiddens, enc_masks, dec_init_state, target_padded)
# Save Tensors to disk
torch.save(enc_hiddens, './sanity_check_en_es_data/enc_hiddens.pkl')
torch.save(dec_init_state, './sanity_check_en_es_data/dec_init_state.pkl')
torch.save(enc_masks, './sanity_check_en_es_data/enc_masks.pkl')
torch.save(combined_outputs, './sanity_check_en_es_data/combined_outputs.pkl')
def question_1d_sanity_check(model, src_sents, tgt_sents, vocab):
""" Sanity check for question 1d.
Compares student output to that of model with dummy data.
"""
print("Running Sanity Check for Question 1d: Encode")
print ("-"*80)
# Configure for Testing
reinitialize_layers(model)
source_lengths = [len(s) for s in src_sents]
source_padded = model.vocab.src.to_input_tensor(src_sents, device=model.device)
# Load Outputs
enc_hiddens_target = torch.load('./sanity_check_en_es_data/enc_hiddens.pkl')
dec_init_state_target = torch.load('./sanity_check_en_es_data/dec_init_state.pkl')
# Test
with torch.no_grad():
enc_hiddens_pred, dec_init_state_pred = model.encode(source_padded, source_lengths)
assert(np.allclose(enc_hiddens_target.numpy(), enc_hiddens_pred.numpy())), "enc_hiddens is incorrect: it should be:\n {} but is:\n{}".format(enc_hiddens_target, enc_hiddens_pred)
print("enc_hiddens Sanity Checks Passed!")
assert(np.allclose(dec_init_state_target[0].numpy(), dec_init_state_pred[0].numpy())), "dec_init_state[0] is incorrect: it should be:\n {} but is:\n{}".format(dec_init_state_target[0], dec_init_state_pred[0])
print("dec_init_state[0] Sanity Checks Passed!")
assert(np.allclose(dec_init_state_target[1].numpy(), dec_init_state_pred[1].numpy())), "dec_init_state[1] is incorrect: it should be:\n {} but is:\n{}".format(dec_init_state_target[1], dec_init_state_pred[1])
print("dec_init_state[1] Sanity Checks Passed!")
print ("-"*80)
print("All Sanity Checks Passed for Question 1d: Encode!")
print ("-"*80)
def question_1e_sanity_check(model, src_sents, tgt_sents, vocab):
""" Sanity check for question 1e.
Compares student output to that of model with dummy data.
"""
print ("-"*80)
print("Running Sanity Check for Question 1e: Decode")
print ("-"*80)
# Load Inputs
dec_init_state = torch.load('./sanity_check_en_es_data/dec_init_state.pkl')
enc_hiddens = torch.load('./sanity_check_en_es_data/enc_hiddens.pkl')
enc_masks = torch.load('./sanity_check_en_es_data/enc_masks.pkl')
target_padded = torch.load('./sanity_check_en_es_data/target_padded.pkl')
# Load Outputs
combined_outputs_target = torch.load('./sanity_check_en_es_data/combined_outputs.pkl')
# Configure for Testing
reinitialize_layers(model)
COUNTER = [0]
def stepFunction(Ybar_t, dec_state, enc_hiddens, enc_hiddens_proj, enc_masks):
dec_state = torch.load('./sanity_check_en_es_data/step_dec_state_{}.pkl'.format(COUNTER[0]))
o_t = torch.load('./sanity_check_en_es_data/step_o_t_{}.pkl'.format(COUNTER[0]))
COUNTER[0]+=1
return dec_state, o_t, None
model.step = stepFunction
# Run Tests
with torch.no_grad():
combined_outputs_pred = model.decode(enc_hiddens, enc_masks, dec_init_state, target_padded)
assert(np.allclose(combined_outputs_pred.numpy(), combined_outputs_target.numpy())), "combined_outputs is incorrect: it should be:\n {} but is:\n{}".format(combined_outputs_target, combined_outputs_pred)
print("combined_outputs Sanity Checks Passed!")
print ("-"*80)
print("All Sanity Checks Passed for Question 1e: Decode!")
print ("-"*80)
def question_1f_sanity_check(model, src_sents, tgt_sents, vocab):
""" Sanity check for question 1f.
Compares student output to that of model with dummy data.
"""
print ("-"*80)
print("Running Sanity Check for Question 1f: Step")
print ("-"*80)
reinitialize_layers(model)
# Inputs
Ybar_t = torch.load('./sanity_check_en_es_data/Ybar_t.pkl')
dec_init_state = torch.load('./sanity_check_en_es_data/dec_init_state.pkl')
enc_hiddens = torch.load('./sanity_check_en_es_data/enc_hiddens.pkl')
enc_masks = torch.load('./sanity_check_en_es_data/enc_masks.pkl')
enc_hiddens_proj = torch.load('./sanity_check_en_es_data/enc_hiddens_proj.pkl')
# Output
dec_state_target = torch.load('./sanity_check_en_es_data/dec_state.pkl')
o_t_target = torch.load('./sanity_check_en_es_data/o_t.pkl')
e_t_target = torch.load('./sanity_check_en_es_data/e_t.pkl')
# Run Tests
with torch.no_grad():
dec_state_pred, o_t_pred, e_t_pred= model.step(Ybar_t, dec_init_state, enc_hiddens, enc_hiddens_proj, enc_masks)
assert(np.allclose(dec_state_target[0].numpy(), dec_state_pred[0].numpy())), "decoder_state[0] is incorrect: it should be:\n {} but is:\n{}".format(dec_state_target[0], dec_state_pred[0])
print("dec_state[0] Sanity Checks Passed!")
assert(np.allclose(dec_state_target[1].numpy(), dec_state_pred[1].numpy())), "decoder_state[1] is incorrect: it should be:\n {} but is:\n{}".format(dec_state_target[1], dec_state_pred[1])
print("dec_state[1] Sanity Checks Passed!")
assert(np.allclose(o_t_target.numpy(), o_t_pred.numpy())), "combined_output is incorrect: it should be:\n {} but is:\n{}".format(o_t_target, o_t_pred)
print("combined_output Sanity Checks Passed!")
assert(np.allclose(e_t_target.numpy(), e_t_pred.numpy())), "e_t is incorrect: it should be:\n {} but is:\n{}".format(e_t_target, e_t_pred)
print("e_t Sanity Checks Passed!")
print ("-"*80)
print("All Sanity Checks Passed for Question 1f: Step!")
print ("-"*80)
def main():
""" Main func.
"""
args = docopt(__doc__)
# Check Python & PyTorch Versions
assert (sys.version_info >= (3, 5)), "Please update your installation of Python to version >= 3.5"
assert(torch.__version__ >= "1.0.0"), "Please update your installation of PyTorch. You have {} and you should have version 1.0.0".format(torch.__version__)
# Seed the Random Number Generators
seed = 1234
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
np.random.seed(seed * 13 // 7)
# Load training data & vocabulary
train_data_src = read_corpus('./sanity_check_en_es_data/train_sanity_check.es', 'src')
train_data_tgt = read_corpus('./sanity_check_en_es_data/train_sanity_check.en', 'tgt')
train_data = list(zip(train_data_src, train_data_tgt))
for src_sents, tgt_sents in batch_iter(train_data, batch_size=BATCH_SIZE, shuffle=True):
src_sents = src_sents
tgt_sents = tgt_sents
break
vocab = Vocab.load('./sanity_check_en_es_data/vocab_sanity_check.json')
# Create NMT Model
model = NMT(
embed_size=EMBED_SIZE,
hidden_size=HIDDEN_SIZE,
dropout_rate=DROPOUT_RATE,
vocab=vocab)
if args['1d']:
question_1d_sanity_check(model, src_sents, tgt_sents, vocab)
elif args['1e']:
question_1e_sanity_check(model, src_sents, tgt_sents, vocab)
elif args['1f']:
# generate_outputs(model, src_sents, tgt_sents, vocab)
question_1f_sanity_check(model, src_sents, tgt_sents, vocab)
else:
raise RuntimeError('invalid run mode')
if __name__ == '__main__':
main()

View File

@@ -0,0 +1,50 @@
But what can you do? You're in the middle of the ocean.
So in this situation too, to decode the information contained in patterns like this, watching alone won't do.
Well, at least, here at CERN.
Let me share with those of you here in the first row.
But hey, sometimes these things are sent to you and you just have to take them when they come.
And then from that point on, you're basically falling.
In the case of gun control, we really underestimated our opponents.
Lorna Sass came and donated books.
And so I showed up in this dark, rambling New York apartment, and she called out to me, and she was in bed.
Now, if President Obama invited me to be the next Czar of Mathematics, then I would have a suggestion for him that I think would vastly improve the mathematics education in this country.
That's how it seems to us.
But some of you do.
But it's not a joke. This is a real headline.
If you look at that truck there, it is the largest truck of its kind of the planet.
I have some cards that maybe, maybe they don't mean anything.
Okay, India.
And he was the King of England, and that was the entire wealth of England at the time.
And so, hopefully one day, we can all have that one extra uncle, that one mother, that one brother, sister, we can have that one more family member to love.
It just wouldn't work.
It suggests that we care about the fight, about the challenge.
JT: Okay.
The benefits of doing so are enormous, the risks minimal.
You know, if you fall in love with a frog, that's it.
Let's start by thinking about the member countries of the OECD, or the Organization of Economic Cooperation and Development.
I hope to arrive at new territories to discover sounds I have never heard before.
A lot of numbers there. A lot of numbers.
There was a burning question though that would not leave me.
They always felt that they could rely on the assurances that nature brought them through the ecosystem of the Gulf.
That's a moral problem but today I'm also going to tell you why it's an economic problem.
My home would have to be whatever I carried around inside me.
Those plaques are plaques we've been installing around North America.
We have to make kids understand that their food choices make a big difference.
This was a world dominated by towering ice sheets, three to four kilometers high, with sweeping grass plains and frozen tundra.
Imagine somewhere in the world: Mumbai, Beijing, New York, London.
He looked at the hut. We went inside.
Started in corporate America, and I was absolutely convinced that it was just about the individual, that women and men would have just the same opportunities.
The arrival of countries like China and India -- between them 38 percent of the world's population -- and others like Indonesia and Brazil and so on, represent the most important single act of democratization in the last 200 years.
So what would happen here if, while the animal is recalling the memory of the blue box, we gave it a couple of mild foot shocks?
I started building this project when I was about 12 or 13 years old.
PM: So tell me, what do you look for in a friend?
In fact, if we count all the individual organisms, we would come at much larger numbers.
So, now you think, how is that possible?
And Intel set aside 475 million dollars to fund the replacement of millions of chips to fix the flaw.
The kids can't sit still long enough to focus, so they don't learn.
You don't forget how to walk because you're thinking about what to have for dinner.
We've got a database of words which we recognize.
I guess most of you by now realize that we do: 300 days of sun.
Fit into this other system and try to become a student."
And then the third one is this idea of the end of oil, this entropic end, where all of our parts of cars, our tires, oil filters, helicopters, planes -- where are the landscapes where all of that stuff ends up?
For mom said, "To be family, is to care and share and to look out for one another.

View File

@@ -0,0 +1,50 @@
Pero, qu puedes hacer? Ests en el medio del ocano.
As que en esta situacin tambin, para decodificar la informacin contenida en los patrones de este tipo, con slo mirar no basta;
Bueno, al menos, aqu en el CERN.
Djenme compartir con ustedes aqu en la primera fila.
Pero a veces estas cosas slo vienen a ti y tienes que aprovecharlas cuando llegan.
Y a partir de eso momento, bsicamente ests cayendo.
En el caso de control de armas, realmente subestimamos a nuestros rivales.
Lorna Sass vino y don libros.
Y llegu a este oscuro, laberntico, departamento en Nueva York, y ella me llam, ella estaba en cama.
Ahora, si el Presidente Obama me invitara a ser el prximo Zar de las Matemticas le hara una sugerencia que mejorara bastante la enseanza de las matemticas en este pas.
Eso es lo que nos parece.
Pero algunos de ustedes s.
Pero no es una broma. Es un titular real,
Si Uds. miran aquel camin de all, es el camin ms grande de su tipo en el planeta.
Tengo algunas cartas que tal vez, quizs, no significan nada.
Bueno, India.
Y l era el Rey de Inglaterra y ah se aglutinaba toda la riqueza de Inglaterra en el momento.
Y as espero que un da todos podamos tener un to extra, esa madre, ese hermano, esa hermana, que podamos tener ese familiar extra que amamos,
No funcion.
Sugiere que nos interesa el combate, el desafo.
JT: Bien
Los beneficios de hacerlo son enormes, los riesgos, mnimos.
O sea, si te enamoras de un sapo, eso es todo.
Comencemos por pensar en los pases miembros de la OCDE, o la Organizacin para la Cooperacin y el Desarrollo Econmicos.
Yo espero llegar a territorios nuevos para descubrir sonidos que nunca haba odo antes.
Con muchos nmeros. Un montn
hubo una pregunta mental que no me abandonaba.
Siempre pensaron que podra confiar en la seguridad que la naturaleza les traa a travs del ecosistema del Golfo.
Este es un problema moral pero hoy tambin dir por qu es un problema econmico.
Mi hogar tendra que ser todo lo que llevaba dentro de m.
Aquellas placas son placas que hemos estado instalando alrededor de Norte Amrica.
Tenemos que hacer comprender a los chicos que las selecciones de comida que hacen marcan grandes diferencias.
Era un mundo dominado por altas capas de hielo, de tres a cuatro kilmetros de altura, con llanuras de hierba y tundra congelada.
Imaginen un lugar en el mundo: Mumbai, Pekn, Nueva York, Londres.
Mir el refugio. Entr.
Empec en el mundo corporativo de EE.UU. y estaba absolutamente convencida de que todo dependa del individuo, que mujeres y hombres tendran las mismas oportunidades.
La llegada de pases como China e India -entre ambas el 38% de la poblacin mundial- y otros pases como Indonesia, Brasil, etc, representa el acto ms importante de democratizacin de los ltimos 200 aos.
Qu pasara aqu si, mientras el animal est recordando la memoria de la caja azul, le damos un par de choques elctricos suaves en el pie?
Comenc con este proyecto cuando tena 12 13 aos de edad.
PM: Entonces, dganme, Qu buscan en una amiga?
S contamos toda la poblacin llegamos a un nmero mucho mayor.
Pensarn, cmo es posible?
E Intel reserv USD 475 millones para financiar el reemplazo de millones de chips para solucionar el defecto.
Los nios no se pueden sentar quietos lo bastante para enfocarse, as que no aprenden.
No olvidas cmo caminar simplemente porque ests pensando qu vas a cenar.
Disponemos de una base de datos de palabras que reconocemos.
Supongo que la mayora de Uds. ya se han dado cuenta de lo que tenemos: 300 das soleados.
Encaja en este otro sistema e intenta ser un estudiante".
Y luego est el tercer captulo que es la idea del fin del petroleo su fin entrpico donde todas nuestras partes de autos, nuestras ruedas, filtros de aceite helicpteros, aviones -- dnde estn los paisajes en los que todas nuestras cosas terminan?
Mi madre deca, "Ser familia es querer, compartir y cuidarnos los unos a los otros.

View File

@@ -0,0 +1,168 @@
{
"src_word2id": {
"<pad>": 0,
"<s>": 1,
"</s>": 2,
"<unk>": 3,
"de": 4,
"que": 5,
"el": 6,
"en": 7,
"la": 8,
"a": 9,
"un": 10,
"y": 11,
"los": 12,
"es": 13,
"del": 14,
"para": 15,
"no": 16,
"este": 17,
"Y": 18,
"una": 19,
"con": 20,
"las": 21,
"lo": 22,
"qu": 23,
"aqu": 24,
"Pero": 25,
"me": 26,
"ser": 27,
"se": 28,
"por": 29,
"pases": 30,
"nuestras": 31,
"slo": 32,
"Bueno,": 33,
"compartir": 34,
"ustedes": 35,
"cosas": 36,
"cuando": 37,
"eso": 38,
"ests": 39,
"Nueva": 40,
"York,": 41,
"ella": 42,
"estaba": 43,
"si": 44,
"le": 45,
"bastante": 46,
"nos": 47,
"Uds.": 48,
"camin": 49,
"ms": 50,
"su": 51,
"Inglaterra": 52,
"toda": 53,
"as": 54,
"espero": 55,
"podamos": 56,
"tener": 57,
"esa": 58,
"ese": 59,
"No": 60,
"Los": 61,
"son": 62,
"problema": 63,
"Mi": 64,
"todo": 65,
"placas": 66,
"mundo": 67,
"como": 68,
"e": 69,
"poblacin": 70,
"Qu": 71,
"est": 72,
"cmo": 73,
"millones": 74,
"fin": 75,
"todas": 76
},
"tgt_word2id": {
"<pad>": 0,
"<s>": 1,
"</s>": 2,
"<unk>": 3,
"the": 4,
"of": 5,
"to": 6,
"that": 7,
"and": 8,
"in": 9,
"a": 10,
"you": 11,
"I": 12,
"have": 13,
"we": 14,
"was": 15,
"this": 16,
"at": 17,
"would": 18,
"one": 19,
"And": 20,
"is": 21,
"about": 22,
"But": 23,
"what": 24,
"are": 25,
"just": 26,
"they": 27,
"so": 28,
"for": 29,
"it": 30,
"all": 31,
"can": 32,
"So": 33,
"like": 34,
"here": 35,
"with": 36,
"them": 37,
"then": 38,
"our": 39,
"if": 40,
"be": 41,
"how": 42,
"look": 43,
"don't": 44,
"The": 45,
"by": 46,
"--": 47,
"where": 48,
"do.": 49,
"me": 50,
"share": 51,
"when": 52,
"on,": 53,
"you're": 54,
"In": 55,
"New": 56,
"she": 57,
"out": 58,
"me,": 59,
"That's": 60,
"some": 61,
"it's": 62,
"not": 63,
"This": 64,
"truck": 65,
"member": 66,
"It": 67,
"care": 68,
"You": 69,
"thinking": 70,
"countries": 71,
"or": 72,
"A": 73,
"lot": 74,
"numbers.": 75,
"me.": 76,
"tell": 77,
"around": 78,
"plaques": 79,
"We": 80,
"make": 81,
"kids": 82,
"most": 83,
"now": 84
}
}

View File

@@ -0,0 +1,83 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
CS224N 2018-19: Homework 4
nmt.py: NMT Model
Pencheng Yin <pcyin@cs.cmu.edu>
Sahil Chopra <schopra8@stanford.edu>
"""
import math
from typing import List
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
def pad_sents(sents, pad_token):
""" Pad list of sentences according to the longest sentence in the batch.
@param sents (list[list[str]]): list of sentences, where each sentence
is represented as a list of words
@param pad_token (str): padding token
@returns sents_padded (list[list[str]]): list of sentences where sentences shorter
than the max length sentence are padded out with the pad_token, such that
each sentences in the batch now has equal length.
"""
sents_padded = []
### YOUR CODE HERE (~6 Lines)
lengths = [ len(sent) for sent in sents]
max_length = max(lengths)
for i in range(len(lengths)):
num_append = max_length - lengths[i]
for j in range(num_append):
sents[i].append(pad_token)
sents_padded = sents
### END YOUR CODE
return sents_padded
def read_corpus(file_path, source):
""" Read file, where each sentence is dilineated by a `\n`.
@param file_path (str): path to file containing corpus
@param source (str): "tgt" or "src" indicating whether text
is of the source language or target language
"""
data = []
for line in open(file_path):
sent = line.strip().split(' ')
# only append <s> and </s> to the target sentence
if source == 'tgt':
sent = ['<s>'] + sent + ['</s>']
data.append(sent)
return data
def batch_iter(data, batch_size, shuffle=False):
""" Yield batches of source and target sentences reverse sorted by length (largest to smallest).
@param data (list of (src_sent, tgt_sent)): list of tuples containing source and target sentence
@param batch_size (int): batch size
@param shuffle (boolean): whether to randomly shuffle the dataset
"""
batch_num = math.ceil(len(data) / batch_size)
index_array = list(range(len(data)))
if shuffle:
np.random.shuffle(index_array)
for i in range(batch_num):
indices = index_array[i * batch_size: (i + 1) * batch_size]
examples = [data[idx] for idx in indices]
examples = sorted(examples, key=lambda e: len(e[0]), reverse=True)
src_sents = [e[0] for e in examples]
tgt_sents = [e[1] for e in examples]
yield src_sents, tgt_sents

View File

@@ -0,0 +1,219 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
CS224N 2018-19: Homework 4
vocab.py: Vocabulary Generation
Pencheng Yin <pcyin@cs.cmu.edu>
Sahil Chopra <schopra8@stanford.edu>
Usage:
vocab.py --train-src=<file> --train-tgt=<file> [options] VOCAB_FILE
Options:
-h --help Show this screen.
--train-src=<file> File of training source sentences
--train-tgt=<file> File of training target sentences
--size=<int> vocab size [default: 50000]
--freq-cutoff=<int> frequency cutoff [default: 2]
"""
from collections import Counter
from docopt import docopt
from itertools import chain
import json
import torch
from typing import List
from utils import read_corpus, pad_sents
class VocabEntry(object):
""" Vocabulary Entry, i.e. structure containing either
src or tgt language terms.
"""
def __init__(self, word2id=None):
""" Init VocabEntry Instance.
@param word2id (dict): dictionary mapping words 2 indices
"""
if word2id:
self.word2id = word2id
else:
self.word2id = dict()
self.word2id['<pad>'] = 0 # Pad Token
self.word2id['<s>'] = 1 # Start Token
self.word2id['</s>'] = 2 # End Token
self.word2id['<unk>'] = 3 # Unknown Token
self.unk_id = self.word2id['<unk>']
self.id2word = {v: k for k, v in self.word2id.items()}
def __getitem__(self, word):
""" Retrieve word's index. Return the index for the unk
token if the word is out of vocabulary.
@param word (str): word to look up.
@returns index (int): index of word
"""
return self.word2id.get(word, self.unk_id)
def __contains__(self, word):
""" Check if word is captured by VocabEntry.
@param word (str): word to look up
@returns contains (bool): whether word is contained
"""
return word in self.word2id
def __setitem__(self, key, value):
""" Raise error, if one tries to edit the VocabEntry.
"""
raise ValueError('vocabulary is readonly')
def __len__(self):
""" Compute number of words in VocabEntry.
@returns len (int): number of words in VocabEntry
"""
return len(self.word2id)
def __repr__(self):
""" Representation of VocabEntry to be used
when printing the object.
"""
return 'Vocabulary[size=%d]' % len(self)
def id2word(self, wid):
""" Return mapping of index to word.
@param wid (int): word index
@returns word (str): word corresponding to index
"""
return self.id2word[wid]
def add(self, word):
""" Add word to VocabEntry, if it is previously unseen.
@param word (str): word to add to VocabEntry
@return index (int): index that the word has been assigned
"""
if word not in self:
wid = self.word2id[word] = len(self)
self.id2word[wid] = word
return wid
else:
return self[word]
def words2indices(self, sents):
""" Convert list of words or list of sentences of words
into list or list of list of indices.
@param sents (list[str] or list[list[str]]): sentence(s) in words
@return word_ids (list[int] or list[list[int]]): sentence(s) in indices
"""
if type(sents[0]) == list:
return [[self[w] for w in s] for s in sents]
else:
return [self[w] for w in sents]
def indices2words(self, word_ids):
""" Convert list of indices into words.
@param word_ids (list[int]): list of word ids
@return sents (list[str]): list of words
"""
return [self.id2word[w_id] for w_id in word_ids]
def to_input_tensor(self, sents: List[List[str]], device: torch.device) -> torch.Tensor:
""" Convert list of sentences (words) into tensor with necessary padding for
shorter sentences.
@param sents (List[List[str]]): list of sentences (words)
@param device: device on which to load the tesnor, i.e. CPU or GPU
@returns sents_var: tensor of (max_sentence_length, batch_size)
"""
word_ids = self.words2indices(sents)
sents_t = pad_sents(word_ids, self['<pad>'])
sents_var = torch.tensor(sents_t, dtype=torch.long, device=device)
return torch.t(sents_var)
@staticmethod
def from_corpus(corpus, size, freq_cutoff=2):
""" Given a corpus construct a Vocab Entry.
@param corpus (list[str]): corpus of text produced by read_corpus function
@param size (int): # of words in vocabulary
@param freq_cutoff (int): if word occurs n < freq_cutoff times, drop the word
@returns vocab_entry (VocabEntry): VocabEntry instance produced from provided corpus
"""
vocab_entry = VocabEntry()
word_freq = Counter(chain(*corpus))
valid_words = [w for w, v in word_freq.items() if v >= freq_cutoff]
print('number of word types: {}, number of word types w/ frequency >= {}: {}'
.format(len(word_freq), freq_cutoff, len(valid_words)))
top_k_words = sorted(valid_words, key=lambda w: word_freq[w], reverse=True)[:size]
for word in top_k_words:
vocab_entry.add(word)
return vocab_entry
class Vocab(object):
""" Vocab encapsulating src and target langauges.
"""
def __init__(self, src_vocab: VocabEntry, tgt_vocab: VocabEntry):
""" Init Vocab.
@param src_vocab (VocabEntry): VocabEntry for source language
@param tgt_vocab (VocabEntry): VocabEntry for target language
"""
self.src = src_vocab
self.tgt = tgt_vocab
@staticmethod
def build(src_sents, tgt_sents, vocab_size, freq_cutoff) -> 'Vocab':
""" Build Vocabulary.
@param src_sents (list[str]): Source sentences provided by read_corpus() function
@param tgt_sents (list[str]): Target sentences provided by read_corpus() function
@param vocab_size (int): Size of vocabulary for both source and target languages
@param freq_cutoff (int): if word occurs n < freq_cutoff times, drop the word.
"""
assert len(src_sents) == len(tgt_sents)
print('initialize source vocabulary ..')
src = VocabEntry.from_corpus(src_sents, vocab_size, freq_cutoff)
print('initialize target vocabulary ..')
tgt = VocabEntry.from_corpus(tgt_sents, vocab_size, freq_cutoff)
return Vocab(src, tgt)
def save(self, file_path):
""" Save Vocab to file as JSON dump.
@param file_path (str): file path to vocab file
"""
json.dump(dict(src_word2id=self.src.word2id, tgt_word2id=self.tgt.word2id), open(file_path, 'w'), indent=2)
@staticmethod
def load(file_path):
""" Load vocabulary from JSON dump.
@param file_path (str): file path to vocab file
@returns Vocab object loaded from JSON dump
"""
entry = json.load(open(file_path, 'r'))
src_word2id = entry['src_word2id']
tgt_word2id = entry['tgt_word2id']
return Vocab(VocabEntry(src_word2id), VocabEntry(tgt_word2id))
def __repr__(self):
""" Representation of Vocab to be used
when printing the object.
"""
return 'Vocab(source %d words, target %d words)' % (len(self.src), len(self.tgt))
if __name__ == '__main__':
args = docopt(__doc__)
print('read in source sentences: %s' % args['--train-src'])
print('read in target sentences: %s' % args['--train-tgt'])
src_sents = read_corpus(args['--train-src'], source='src')
tgt_sents = read_corpus(args['--train-tgt'], source='tgt')
vocab = Vocab.build(src_sents, tgt_sents, int(args['--size']), int(args['--freq-cutoff']))
print('generated vocabulary, source %d words, target %d words' % (len(vocab.src), len(vocab.tgt)))
vocab.save(args['VOCAB_FILE'])
print('vocabulary saved to %s' % args['VOCAB_FILE'])