ChatGPT简介
ChatGPT&DALLE2是OpenAI的最新研究成果,在量子位看到他的强大功能后,就自己试玩了一下,比如我让ChatGPT帮我写一个GraphSage模型,ChatGPT先简单解释了一下GraphSage,然后写出了不错的PyTorch代码 (详见见示例一),是不是很神奇?
ChatGPT&DALLE2试用攻略
在我将量子位的公众号文章转发朋友圈之后,很多人遇到了怎么注册的问题,China是不允许注册的,注册过程需要手机号,一种简单的方式是找国外的同学/朋友借,另一种是直接淘宝买,只有几块钱。直接登陆,在下图输入框输入你想让他做的事,点击右侧小三角(DALLE2是Generate按钮)即可。
示例一 写代码
写东西需要用ChatGPT,网址ChatGPT
import torch
import torch.nn as nn
class GraphSAGE(nn.Module):
def __init__(self, input_dim, hidden_dim, output_dim, num_samples):
super(GraphSAGE, self).__init__()
self.input_dim = input_dim
self.hidden_dim = hidden_dim
self.output_dim = output_dim
self.num_samples = num_samples
self.embedding = nn.Embedding(input_dim, hidden_dim)
self.aggregator = nn.Linear(hidden_dim * num_samples, hidden_dim)
self.classifier = nn.Linear(hidden_dim, output_dim)
def forward(self, nodes, neighbors):
# Extract node embeddings
node_embeddings = self.embedding(nodes)
# Sample and aggregate neighbor embeddings
neighbor_embeddings = [self.embedding(neighbors[:, i])
for i in range(self.num_samples)]
neighbor_embeddings = torch.cat(neighbor_embeddings, dim=1)
aggregated_neighbors = self.aggregator(neighbor_embeddings)
# Combine node and aggregated neighbor embeddings
combined = torch.cat([node_embeddings, aggregated_neighbors], dim=1)
# Predict node labels
return self.classifier(combined)
示例二 写诗
示例三 画画
画画需要用DALLE2,网址DALL·E