惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 【当耐特】
K
Kaspersky official blog
V
Vulnerabilities – Threatpost
Hacker News - Newest:
Hacker News - Newest: "LLM"
Security Archives - TechRepublic
Security Archives - TechRepublic
S
Secure Thoughts
I
Intezer
TaoSecurity Blog
TaoSecurity Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Spread Privacy
Spread Privacy
A
About on SuperTechFans
NISL@THU
NISL@THU
The GitHub Blog
The GitHub Blog
Hugging Face - Blog
Hugging Face - Blog
S
Security @ Cisco Blogs
S
SegmentFault 最新的问题
G
Google Developers Blog
B
Blog
N
News and Events Feed by Topic
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Google DeepMind News
Google DeepMind News
V2EX - 技术
V2EX - 技术
V
Visual Studio Blog
MyScale Blog
MyScale Blog
Webroot Blog
Webroot Blog
Vercel News
Vercel News
IT之家
IT之家
Microsoft Security Blog
Microsoft Security Blog
Last Week in AI
Last Week in AI
Y
Y Combinator Blog
S
Security Affairs
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Stack Overflow Blog
Stack Overflow Blog
P
Proofpoint News Feed
L
Lohrmann on Cybersecurity
博客园 - 叶小钗
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Know Your Adversary
Know Your Adversary
T
Tailwind CSS Blog
F
Fortinet All Blogs
D
DataBreaches.Net
博客园 - Franky
博客园_首页
H
Heimdal Security Blog
宝玉的分享
宝玉的分享
阮一峰的网络日志
阮一峰的网络日志
Attack and Defense Labs
Attack and Defense Labs
Project Zero
Project Zero
雷峰网
雷峰网

夜行人

回家路上 第一期的直播演示项目 震动检测器 正能量 在线参观CodeLab Neverland 发布 CodeLab Adapter 3.3.1 DynamicTable 之 纸糊方向盘 CodeLab DynamicTable: 一个可实施的技术方案 CodeLab Insight 发布 Alpha 版 情人节 Home Assistant 周报 && IoT 周报 (02) Joplin: 关注隐私的 Evernote 开源替代软件 浏览器的未来与 Web 传感器 Home Assistant 周报 && IoT 周报 (01) 百宝箱(01) 论自由 介绍 WebThings Home Assistant 周报 && iot 周报 (00) 百宝箱(00) 毛姆读书心得 传世之作 周末徒步 航班 躲雨 夏令营途中 [译]思想--作为一种技术 The future of coding 美国之行 三门问题的程序模拟 从Python转向Pharo https://blog.just4fun.site/post/iot/iot-open-source-projects/ Python异步编程笔记 https://blog.just4fun.site/post/iot/iot-open-source-hardware-community/ 万物积木化开发者社区 CodeLab ❤️ Blender Scratch3技术分析之云变量 API(第7篇) [译]对管道(Pipes)的偏爱 [译]提出正确的问题比得到正确答案更重要 蓝牙设备与Scratch3.0 创建你的第一个Scratch3.0 Extension Scratch3技术分析之项目内部数据(第6篇) Scratch3技术分析之社区 API(第5篇) Scratch3技术分析之User API(第4篇) Scratch3技术分析之项目主页API(第3篇) Scratch3技术分析之静态资源API(第2篇) Scratch3.0、micro:bit与Windows7 https://blog.just4fun.site/post/iot/zerynth-vs-micropython/ 核聚变、方所与半宅空间 可视化编程为何是个糟糕的主意 codelab.club周末聚会 关于codelab.club '下一件大事'是一个房间 Hungry Robot - Eat everything 编程作为一种思考方式 今日简史 史蒂夫·乔布斯传 罗素自选文集 https://blog.just4fun.site/post/edx/tianjin-scratch-ai/ https://blog.just4fun.site/post/edx/richie-cms-openedx/ 徒步武功山 WebUSB与micro:bit 积木化编程与3D场景 夜宿武功山顶 scratch3-adapter接入优必选Alpha系列机器人 https://blog.just4fun.site/post/edx/video-migration-note/ scratch3-adapter重构笔记 https://blog.just4fun.site/post/edx/edx-community-members/ 两种硬件编程风格的比较 使用micro:bit自制PPT翻页笔 柏拉图对话集 scratch3.0 + micro:bit 七月电影放映计划 非营利组织的管理 Screenly--用树莓派让任何屏幕变为可编程的数字标牌 以最佳实践开始你的Django项目 micro:bit与事件驱动 为Scratch3.0设计的插件系统(上篇) OCR应用一例 近两年读过的一些好书 blockly开发之使用python驱动浏览器中的turtle(2) 牛顿新传 文学理论入门 逻辑的引擎 人生的意义 blockly开发之生成并运行js代码(1) blockly开发之hello world(0) micro:bit使用笔记 神器之Termux https://blog.just4fun.site/post/iot/micropython-notes/ Cozmo what is this Scratch的前世今生 下段旅程 我行在远方 爆裂 途中杂记 https://blog.just4fun.site/post/edx/open-edx-startup/ cozmo系列之入门 - 有性格且可编程的机器人 PaperWeekly开发笔记 创业二三事 blockly与结对编程
CodeLab Adapter ❤️ Jupyter/Python
种瓜 · 2019-07-30 · via 夜行人

文章目录

前言

上周与@曾老师一起在杭州湾参加为期四天的AI夏令营,做一些技术支持和辅导的工作,体验颇似黑客马拉松。

活动中教育者与学习者们皆十分用心,有些同学为了做好手头项目彻夜未眠。

由于Alan Kay和Seymour Papert的影响,活动过程中,我的视角一直放在编程/软件环境等基础设施上。大家都在使用Python编程(下个十年的编程教育应该都会基于它),触及的编程环境五花八门,许多工具恶劣而狂野,以至于教育者和学习者所做的努力中起码有一半用于与糟糕的技术环境搏斗。

demo

夏令营的几天里一直在与曾老师讨论如何为初学者设计一种舒适的入门环境,既能自由探索又安全可控。

我们想到Jupyter + CodeLab Adapter。活动结束回到酒店洗完澡,做了个原型:

对应源码(调整后):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
from codelab_adapter_client import SimpleNode
node = SimpleNode()

node.simple_publish("开启音乐")

node.simple_publish("下一个造型")

import time
for i in range(10):
    time.sleep(0.2)
    node.simple_publish("落下礼花")

# 完整演奏
import time
node.simple_publish("开启音乐")
time.sleep(0.2)
for i in range(30):
    time.sleep(0.2)
    node.simple_publish("下一个造型")
    time.sleep(0.2)
    for i in range(5):
        node.simple_publish("落下礼花")

在这个例子里,Jupyter中的Python代码可以与Scratch3.0环境自由互动。

技术层面,往Jupyter中引入codelab_adapter_client,使用AdapterNode与CodeLab Adapter 2.0建立连接。由于CodeLab Adapter 2.0已经接入了Scratch3.0. 所以用户可以使用Python代码为Scratch中的角色编程(everything is a message)。Python中的任何能力都可以引入到Scratch3.0中,这可不是简单的积木翻译,是两个环境之间的交互和彼此增强!

这也是CodeLab对如何从Scratch过渡到Python?这一问题做出的一个回答。

更多的想象空间

由于CodeLab Adapter 2.0已经接入了数十种软硬件

当我们使用codelab_adapter_client将Jupyter接入CodeLab Adapter 2.0时,我们就可以将Jupyter作为这数十种软硬件的编程平台!

Jupyter是目前最理想Python/数据分析/人工智能的编程教育环境。关于Jupyter在教育上的意义可以参考使用IPython Notebook来学习编程

CodeLab Adapter 1.0致力于将万物带入Scratch,实现education as life的目标。CodeLab Adapter 2.0则将万物带入到Python教育中。物联网、人工智能、开源硬件,你现在可以使用Python在Jupyter中与这些东西交互。

机器人教学

涉及的代码如下:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from codelab_adapter_client import AdapterNode
from codelab_adapter_client.topic import JUPYTER_TOPIC

class MyRobotNode(AdapterNode):
    def __init__(self):
        super().__init__()
        self.EXTENSION_ID = "eim/vector"
        self.message = {"topic": JUPYTER_TOPIC, "payload": {"content": "robot.behavior.say_text('hello')"}}

    def forward(self,distance,speed):
        self.message["payload"]["content"] = f"robot.behavior.drive_straight(anki_vector.util.distance_mm({distance}), anki_vector.util.speed_mmps({speed}))"
        self.publish(self.message)
    def turn_left(self,degrees,speed):
        self.message["payload"]["content"] = f"robot.behavior.turn_in_place(anki_vector.util.degrees({degrees}), speed=anki_vector.util.degrees({speed}))"
        self.publish(self.message)

    def say(self,content):
        self.message["payload"]["content"] = f"robot.behavior.say_text('{content}')"
        self.publish(self.message)
     
robot = MyRobotNode()
robot.forward(100,100)
robot.turn_left(90,180)
robot.say("hello")

from pypinyin import  lazy_pinyin
pinyin = "".join(lazy_pinyin('肚子 好饿 去吃 午饭啦'))
print(pinyin)
robot.say(pinyin)

CodeLab Adapter 2.0近期计划发布,它试图去聚合所有有趣而设计精良的东西,无论是积木化界面、优秀的Python编程环境(Jupyter)、还是整个日常生活空间,目标是为学习者提供完整而舒适的编程环境。

线上学习平台

@曾老师近期在参与一个AI线上学习平台的构建,将基于Open edX + Jupyter

Open edX提供了绝佳的学习系统,也许是目前全球最强大的学习系统,它拥有绝佳的开放性和丰富的生态。而Jupyter则是目前最理想的Python//数据分析/机器学习/AI编程工具。@曾老师希望结合两者,为学习者提供舒适而高效的学习环境,初学者不必为环境的搭建焦头烂额,目前斯坦福大学和UC伯克利都在使用Open edXJupyter作为编程教育平台。

CodeLab Adapter 2.0也将该平台的基础实施之一,将平台能力延伸到任何事物上,无论是机器人教学、物联网教学还是开源硬件教学。学习者只需要在Jupyter中编程,就可以控制CodeLab Adapter 2.0接入的任何事物。

在本地运行Jupyter,连接CodeLab Adapter 2.0是容易的,但云端似乎有些不同。 Open edX使用jupyterhubJupyter运行在云端docker容器里,如此一来,线上平台的Python代码如何与本地硬件交互呢?

策略是利用Javascript!浏览器中Javascript既能与云端Jupyter Python Kernel交互,又能与本地的CodeLab Adapter 2.0交互(我们在Scratch3.0中也是这么做的),具体原理用以下代码演示:

1
2
3
from IPython.core.display import Javascript, display
for i in range(3):
    display(Javascript(f"console.log('{i}') //websocket send/recv message <-> CodeLab Adapter 2.0")) 

参考