Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
base-image-test
Commits
697496bc
Commit
697496bc
authored
Oct 11, 2024
by
chenpangpang
Browse files
feat: add tensorflow test script
parent
825c4b6a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
0 deletions
+36
-0
.gitignore
.gitignore
+1
-0
tensorflow/bert/infer.py
tensorflow/bert/infer.py
+16
-0
tensorflow/mnist/train.py
tensorflow/mnist/train.py
+19
-0
torch/gpt2/infer.py
torch/gpt2/infer.py
+0
-0
torch/hf_down.py
torch/hf_down.py
+0
-0
torch/stable-diffusion-v1-4/infer.py
torch/stable-diffusion-v1-4/infer.py
+0
-0
No files found.
.gitignore
0 → 100644
View file @
697496bc
.idea
tensorflow/bert/infer.py
0 → 100644
View file @
697496bc
import
tensorflow
as
tf
import
tensorflow_hub
as
hub
import
tensorflow_text
as
text
text_input
=
tf
.
keras
.
layers
.
Input
(
shape
=
(),
dtype
=
tf
.
string
)
preprocessor
=
hub
.
KerasLayer
(
"https://kaggle.com/models/tensorflow/bert/TensorFlow2/en-uncased-preprocess/3"
)
encoder_inputs
=
preprocessor
(
text_input
)
encoder
=
hub
.
KerasLayer
(
"https://kaggle.com/models/tensorflow/bert/TensorFlow2/en-uncased-l-12-h-768-a-12/3"
,
trainable
=
True
)
outputs
=
encoder
(
encoder_inputs
)
pooled_output
=
outputs
[
"pooled_output"
]
# [batch_size, 768].
sequence_output
=
outputs
[
"sequence_output"
]
# [batch_size, seq_length, 768].
embedding_model
=
tf
.
keras
.
Model
(
text_input
,
pooled_output
)
sentences
=
tf
.
constant
([
"(your text here)"
])
print
(
embedding_model
(
sentences
))
\ No newline at end of file
tensorflow/mnist/train.py
0 → 100644
View file @
697496bc
import
tensorflow
as
tf
mnist
=
tf
.
keras
.
datasets
.
mnist
(
x_train
,
y_train
),(
x_test
,
y_test
)
=
mnist
.
load_data
()
x_train
,
x_test
=
x_train
/
255.0
,
x_test
/
255.0
model
=
tf
.
keras
.
models
.
Sequential
([
tf
.
keras
.
layers
.
Flatten
(
input_shape
=
(
28
,
28
)),
tf
.
keras
.
layers
.
Dense
(
128
,
activation
=
'relu'
),
tf
.
keras
.
layers
.
Dropout
(
0.2
),
tf
.
keras
.
layers
.
Dense
(
10
,
activation
=
'softmax'
)
])
model
.
compile
(
optimizer
=
'adam'
,
loss
=
'sparse_categorical_crossentropy'
,
metrics
=
[
'accuracy'
])
model
.
fit
(
x_train
,
y_train
,
epochs
=
5
)
model
.
evaluate
(
x_test
,
y_test
)
\ No newline at end of file
gpt2/infer.py
→
torch/
gpt2/infer.py
View file @
697496bc
File moved
hf_down.py
→
torch/
hf_down.py
View file @
697496bc
File moved
stable-diffusion-v1-4/infer.py
→
torch/
stable-diffusion-v1-4/infer.py
View file @
697496bc
File moved
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment