Interpolation in Tensorflow

I recently had to interpolate some data in the setting of training some machine learning code, coded in Tensorflow. It turns out that the interpolator doesn’t work with the compiled Tensorflow functions, which is usually recommended for faster execution.
This is quite annoying, but has a simple solution using the


in Tensorflow.

import tensorflow as tf
import numpy as np
from scipy.interpolate import NearestNDInterpolator
x = np.linspace(0, 10, 10)
y = np.linspace(0, 10, 10)
z = np.sin(x + y)
interp = NearestNDInterpolator(list(zip(x, y)), z)points = tf.constant([[1, 2],
[3, 4],
[5, 6]], dtype=tf.float64)@tf.function
def test(x):
return interp(x)@tf.function
def test_2(x):
return tf.numpy_function(interp, inp=[x], Tout=tf.float64)print(test_2(points)) # Works
print(test(points)) # Doesn't work

Yet another qualm

This past Sunday was the only day when a broken clock could be potentially correct for more than two times a day.

But you know what’s annoying? Changing the clocks on ovens and cars by pressing the “H” button eleven times.

Turkey Trip

I went to Turkey for a total of ten days this past October, and it was a great trip. The amount of cultural heritage everywhere is unprecedented for me; it felt that every patch of land had some sort of historical significance. This was paired with awesome, unique natural features that I’ve never seen anywhere else.

The trip started in Istanbul where I only stayed for two nights. One could theoretically stay for far longer in this bustling metropolis, but I felt that I saw enough. It was also incredibly overwhelming in terms of people density, even for me who actually enjoys NYC.

The highlights in Istanbul is quite easily the Hagia Sophia, and the Basilica Cistern. The former is free as it’s a working mosque, but the line is wild at peak times. I went during the morning right before it opened, and the line winded down a side street. I did have a nice conversation with a short British woman and her six feet four husband. The Basilica Cistern does cost money, and the line is still an issue. I managed virtually zero wait by going near closing time. Nevertheless, these historical structures were breathtaking.

Hagia Sophia
Basilica Cistern
Hagia Sophia interior
Topkapi Palace

Other highlights include Topkapi palace with its many antiquities, and a cruise around the Bosphorus strait. Unfortunately for me, the Blue Mosque was still under renovations and I couldn’t appreciate the full splendor.

Besides the sights, Istanbul was very pedestrian-friendly and had a wealth of shopping. My excursion into the Grand Bazaar was unfruitful shopping-wise, but it’s still a sight to behold the many shops. I went with a cheap culinary experience, which was quite easy but I did overspend one meal… by around 2 dollars. I think the lesson is to avoid places with bi-modal reviews.

Grand Bazaar

I then went to Selcuk and the nearby Ephesus, eponym of the book of Ephesians. Here is really where the history became tangible (tbh, my Caliphates history is pretty rough): I probably walked the same steps that the apostle Paul and Mary strolled two thousand years ago. The actual Roman town was very well preserved, and it felt more Roman than Rome due to the lack of cars around. Finally, I went by a former Sevens Wonders: the Temple of Artemis. Unfortunately, the only thing that remains is a single column and the grounds are mostly peddlers.

There were a few other attractions around Selcuk such as the place where Mary allegedly died, a local redoubt, and the ruins of St. John Basilica. Selcuk itself was quite fun to walk around with cheap food and locals everywhere. I far enjoyed my time there compared to Istanbul.

Ephesus theater
Temple of Artemis
Library of Celsus

Afterwards, I took a day trip to Pamukkale, which was arguably one of the highlights of the trip. Due to the contents in the hot springs, an alien-like waterfall structure built up. The Romans realized this and built a town around it with a well-preserved theater. The star was definitely the warm waterfall though. This place deserves its UNESCO heritage site designation. But maybe the most curious thing is the number of “influencers” trying to take their Insta pics…

Hierapolis theater
Pamukkale falls
Pamukkale falls

Finally, I went to Ankara to visit an old office mate. We visited the local museum where I saw the skull of the King Midas, much to my surprise. We also ended up eating a good deal of food. Speaking of dining, I really do enjoy the freshness of the cuisine in Turkey. It seems that the cherry tomatoes in Turkey did have more flavor with an basil-esque aftertaste. There are also a lot more more lamb-based foods plus fresh Mediterranean seafood which I enjoyed. Unfortunately, the food was not as cheap as I thought it would be. Thanks Obama.

Lastly, the trip ended up in Cappadocia. The area felt like the hoodoos that I saw in New Mexico, but just at a far larger scale with more varied terrain and water. Furthermore, there were old Christian churches carved into the features. This area was truly unique in both the historical significance and natural wonders. In addition, there are also the possibility for balloon rides! I think I could’ve spend another day there with how many features that I didn’t get to see.

Cappadocia church
Cappadocia houses
Cappadocia houses

As for some closing thoughts, I felt a bit bad for not talking to that many Turkish people. I stayed in hotels (in fact, got upgraded from a hostel since it was low season) and mainly kept to myself due to possible scams. Nevertheless, the people I talked to were all nice and respectful to a clear foreigner.

Lastly, there are a lot of cats… petting them all would’ve took forever. 

Two Trips

Recently went on a fifteen mile round trip hike to Jordan Hot Springs in the Gila Wilderness. I’m still not used to the variation in the landscape of New Mexico. The trail mostly lies within a canyon with a river carving through it.

The most fun part of the trail is definitely the river crossings. Successfully fording a river really does make one feel like an adventurer. Oh, and the hot springs was nice to I guess. It’s nice that I didn’t die from the amoeba.

Then the other day, I finally went to a concert in New Mexico to a band that I know and love. The Head and The Heart was playing at the Ladder to the Moon festival. On a whim, I decided to drive the 2 hours to northern NM and see them during the lunar new moon.

It was an awesome show.

On a side note, having great ear plugs really make concerts so much better.


bête noire

a person or thing strongly detested or avoided.


producing no useful result.

Realist Musings

This stream of consciousness will be a classic case of Dunning-Kruger effect, speaking as someone who’s education in international relation began and ended in an “Introduction to IR” class where I ended up with a solid B, never spoke up in class, and generally got confused while doing the readings.

But one of the classic theories I remember is the Golden Arches Theory of Peace. It states that:

No two countries that both have a McDonald’s have ever fought a war against each other

which, given the current situation, can probably be declared officially dead. Side note, does the theory apply if McDonald’s retroactively pulls out of Russia?

Perhaps the better theory should have the caveat that both countries have functioning democracies. This seems better supported by the small data set at hand: the main counterexamples on Wikipedia (with the exception of Israel/Lebanon) seems to justify the addendum.

This makes intuitive sense. Having a McDonald’s franchise necessarily mean that the country is fairly stable, has a solid logistical base, and can generate income. However, this doesn’t mean much in terms of politics of the country. Case in point, China.

It’s also worrying to see what has happened in Ukraine from the lens that it’s the death rattle of Putin. There’s been rumors of Putin’s declining health, and perhaps this is his need to create a “legacy”? This doesn’t bode well for the Taiwan-China situation either, as China has a huge demographic time bomb caused by the one-child policy. What will happen once that starts to happen?

I really don’t need this century to have another global-order-redefining war.

Putnam 2020 A2

For $k$ a non-negative integer, evaluate
\sum_{j=0}^k 2^{k-j} \binom{k +j}{j}.

Apparently, I only know how to do induction anymore now but this problem is straightforward using it. We suppose the inductive hypothesis, and assume that for a fixed $k$ that
\sum_{j=0}^k 2^{k-j} \binom{k +j}{j} = 2^{2k}.
We will proceed to show
\sum_{j=0}^{k + 1} 2^{k + 1-j} \binom{k + 1 +j}{j} = 2^{2k + 2}.

By a simple binomial identity, we have
\sum_{j=0}^{k + 1} 2^{k + 1-j} \binom{k + 1 +j}{j} &= \sum_{j=0}^{k + 1} 2^{k + 1-j} \binom{k+j}{j} + \sum_{j=0}^{k + 1} 2^{k + 1-j} \binom{k +j}{j – 1}.
Let $A$, $B$ be the first and second term respectively on the right hand side, then
A &= 2\sum_{j=0}^{k} 2^{k-j} \binom{k+j}{j} + \binom{2k + 1}{k+1} \\
&= 2^{2k + 1} + \binom{2k + 1}{k+1}.
For the other term,
B &= \sum_{j=1}^{k + 1} 2^{k + 1-j} \binom{k +j}{j – 1} \\
&= \sum_{j=0}^{k} 2^{k-j} \binom{k +1 +j}{j} \\
&= \frac{1}{2} \sum_{j=0}^{k + 1} 2^{k + 1-j} \binom{k +1 +j}{j} – \frac{1}{2} \binom{2k + 2}{k + 1}.
Thus, we rearranging, we have our result
\frac{1}{2}\sum_{j=0}^{k + 1} 2^{k + 1-j} \binom{k + 1 +j}{j} &= 2^{2k+1} + \binom{2k + 1}{k+1} – \frac{1}{2} \binom{2k + 2}{k + 1} \\
&= 2^{2k+1}.

New Mexico Tourism

Within the last month, I’ve hosted a friend and my brother in Albuquerque meaning I had to think of things to take them to do. This was my list that doesn’t include climbing around the state (which warants a post on its own one day), and my opinions:

  1. Meow Wolf: a must do. Unique, fun and modern. Truly an art museum that is worth every dime. One can easily take the opportunity while up in Santa Fe to eat some better food, and visit their downtown (which is better than ABQ’s Old Town)… speaking of…
  2. Sandia Tramway and ABQ oldtown: I honestly don’t think ABQ as a city is very worthwhile to visit. The Sandia Tramway is nice for an overview of the city and to get mountain air, but it’s fairly expensive for the experience. I think La Luz might be the better option for those who are young and fit. Old Town is really just a shopping area and pales in comparison to the Santa Fe’s corresponding area. The only thing that I liked was the BioPark and Explora (but this zoo/garden/aquarium and museum are not unique to ABQ).
  3. Petroglyph National Monument: I took both people to Piedras Marcadas canyon trail for the petroglyphs. It’s honestly not that spectacular of a hike, considering the flatness and the fact that it’s by a suburb. It is useful as a first day visit to acclimate to the altitude.

  4. Bisti Badlands/Valley of Dreams: for the outdoorsy-type, I thought this was a fantastic place (one of the pictures on the top of my banner is from there). The one draw back is that it is a full day trip, and summer is brutal there. But for geologists or other just curious types, definitely worth a visit.

  5. Ten Thousand Waves Spa: I brough my friend there to let him relax. It wasn’t too expensive once we split the cost, and I did enjoy my time there. The caveat is that there are closer spas nearby in ABQ, but non had the Japanese aesthestic that I wanted. I personally really enjoyed my time there.

  6. Tinkertown Museum: a hidden gem. I loved the little place. It’s filled with tchotchkes, figurines and models which one person collected over his lifetime. On the surface, this may sound mundane, but the craftsmanship and themes really brings the exhibits together. Truly great. This is on the Turqoise road which allows one to visit Madrid, NM on the way.

  7. Mount Wheeler Hike: hard one. Do not attempt if not fit. The payoff is great though, and it’s a very nice trip up to Taos (visit Chokola, unrelated to Dracula, for great choclate) to escape the heat. One can make this a quick weekend trip by camping in the valley, then hiking to Lake Williams rather than the summit (only 4 miles and much less strenous).

The Last Thing He Told Me

I honestly spent some three months trying to read Donna Tartt’s The Little Friend. It was well written, and I generally like her written styles (I did finish The Goldfinch and The Secret History) but somehow this particular novel didn’t work for me. Out of frustration, I just borrowed the most popular book on Libby which is available which happens to be the titular book written by Laura Dave.

Oh boy was the difference in writing stark. It was distinctively less sophisticated and the vocabulary more elementary. It made for much faster reading meaning the novel was done in less than a week. This is also probably due to the over-explanation at all points.

Was it worth it? Eh.

I honestly thought the plot was unrealistic with hackneyed tropes: a teenager being difficult, the protagonist doing things for “love”, a clear misunderstanding of what technology can do. Still, I finished it.

Why is that? I don’t know.

An Improvisational Note

For the last few weeks, I’ve been taking a beginner improv class as a way to meet people and broaden my horizons. Overall, the experience has been highly positive and I’ve learned a great deal on not just improv, but comedy as a whole.

The first phrase I have been telling friends what the classes are like is “adult daycare.” Certainly a lowbrow phrase, but how else can one interpret a class where we try to channel different levels of an animal? Or one where we try to perform a Busby Berkeley dance without a priori discussion? Another great example of an improv game that I (and I suspect many kids) would enjoy is equivalent to the everyone-tell-a-story-but-can-only-say-one-word.

At some point, silliness from all becomes just straight up fun. The key phrase there is “from all”: we all paid for the lessons, and thus had a stake in being whimsical. I’m glad none of my classmates  hesitated to do any of the exercises and in fact most put themselves out there. This was one of the lessons from improv: action with confidence supersedes hesitancy, especially if no one knows what you’re doing.

Joking aside, it’s been actually very informative on what exactly makes good improv, well, good. Some can be attributed to the spontaneity of the performers, but there are general frameworks which help add structure. For one, we learned that it’s much easier to grasp a scene if we self-impose a goal and also add some sort of familiar relationships between the characters. People can grasp onto the characters much easier that way, and there’s established frameworks to manipulate.

As something that I signed up for willy-nilly turned out to be quite the happy accident. I really did enjoy the class and the challenges it gave me.