This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Parallelizing | |
List<Integer> transactionsIds = | |
transactions.parallelStream() | |
.filter(t -> t.getType() == Transaction.GROCERY) | |
.sorted(comparing(Transaction::getValue).reversed()) | |
.map(Transaction::getId) | |
.collect(toList()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Traditional Method | |
List<Transaction> groceryTransactions = new Arraylist<>(); | |
for(Transaction t: transactions){ | |
if(t.getType() == Transaction.GROCERY){ | |
groceryTransactions.add(t); | |
} | |
} | |
Collections.sort(groceryTransactions, new Comparator(){ | |
public int compare(Transaction t1, Transaction t2){ | |
return t2.getValue().compareTo(t1.getValue()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// RowMapper using Anonymous Class | |
List<User> users = jdbcTemplate.query( | |
"SELECT USER_ID, USERNAME FROM USER", new RowMapper<User>() { | |
@Override | |
public User mapRow(ResultSet rs, int rowNum) throws SQLException { | |
User user = new User(); | |
user.setUserId(rs.getLong("USER_ID")); | |
user.setUsername(rs.getString("USERNAME")); | |
return user; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Anonymous Runnable | |
Runnable r1 = new Runnable(){ | |
@Override | |
public void run(){ | |
System.out.println("Hello world one!"); | |
} | |
}; | |
r1.run(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
"""텐서보드에서 요약정보(summaries)를 보여주는 간단한 MNIST 분류기 | |
이 소스는 별로 특별하지 않은 MNIST 모델이다. 하지만, 텐서보드 그래프 탐색기에서 그래프를 읽을수 있게 | |
tf.name_scope를 사용하고, 텐서보드에서 의미있게 그룹핑되어 보여질 수 있도록 요약 태그(summary tag) | |
를 사용하는 방법을 배우기 위한 좋은 예제이다. | |
이 예제는 텐서보드 대시보드의 기능들을 보여준다. | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
render_deepdream(T(layer)[:,:,:,139], img0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
render_deepdream(tf.square(T('mixed4c')), img0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
img0 = PIL.Image.open('pilatus800.jpg') | |
img0 = np.float32(img0) | |
showarray(img0/255.0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def render_deepdream(t_obj, img0=img_noise, | |
iter_n=10, step=1.5, octave_n=4, octave_scale=1.4): | |
t_score = tf.reduce_mean(t_obj) # defining the optimization objective | |
t_grad = tf.gradients(t_score, t_input)[0] # behold the power of automatic differentiation! | |
# split the image into a number of octaves | |
img = img0 | |
octaves = [] | |
for i in range(octave_n-1): | |
hw = img.shape[:2] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
render_lapnorm(T(layer)[:,:,:,65]+T(layer)[:,:,:,139], octave_n=4) |