Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6de9a1959b0f3ccd2b9e70f1b42a4f295af1bea89e4779c1e0fe5753bc609be7
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import paddle

input_meta = {"inputs": {"shape": [1, 3, 224, 224], "dtype": "float32"}}
11 changes: 11 additions & 0 deletions graph_net/samples/paddle_samples/vision/squeezenet1_1/model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import paddle
from paddle.vision.models import squeezenet1_1


class GraphModule(paddle.nn.Layer):
def __init__(self):
super(GraphModule, self).__init__()
self.model = squeezenet1_1(pretrained=False)

def forward(self, inputs):
return self.model(inputs)

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import paddle

weight_meta = {}
28 changes: 28 additions & 0 deletions graph_net/tests/test_squeezenet1_1_extract.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import paddle
import os
from paddle.vision.models import squeezenet1_1


def extract_squeezenet():
# 环境准备
os.environ["FLAGS_enable_pir_api"] = "1"
paddle.enable_static()

# 捕获计算图
main_program = paddle.static.Program()
with paddle.static.program_guard(main_program):
inputs = paddle.static.data(
name="inputs", shape=[1, 3, 224, 224], dtype="float32"
)
model = squeezenet1_1(pretrained=False)
out = model(inputs)

# 保存结果
save_path = "squeezenet1_1.json"
with open(save_path, "w") as f:
f.write(str(main_program))
print(f"提取完成,文件已生成至: {save_path}")


if __name__ == "__main__":
extract_squeezenet()