Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: invalid syntax #113

Open
RuoyuChen10 opened this issue Jun 20, 2023 · 1 comment
Open

SyntaxError: invalid syntax #113

RuoyuChen10 opened this issue Jun 20, 2023 · 1 comment

Comments

@RuoyuChen10
Copy link

Thanks for your contribution. When I try to train a face model:

from tensorflow import keras
import losses, train, models
import tensorflow_addons as tfa

# Celeb-A
data_path = '/home/cry/J-20/Datasets/CelebA/Img_cls/img_align_celeba'
model_path = "ckpt/TT_r100_max_pool_E_prelu_dr04_lr_01_l2_5e4_adaface_emb512_sgd_m09_bs512_glint360k_64_only_margin_SG_scale_true_bias_false_random_100_partial4_basic_model_latest.h5"
save_path = "keras-ArcFace-R100-Celeb-A.h5"


eval_paths = ['/datasets/faces_emore/lfw.bin', 
              '/datasets/faces_emore/cfp_fp.bin', 
              '/datasets/faces_emore/agedb_30.bin']

tt = train.Train(data_path, save_path=save_path, eval_paths=eval_paths,
                model=model_path, batch_size=512, random_status=0,
                lr_base=0.1, lr_decay=0.5, lr_decay_steps=16, lr_min=1e-5)

optimizer = tfa.optimizers.SGDW(learning_rate=0.1, momentum=0.9, weight_decay=5e-5)
sch = [
#   {"loss": losses.ArcfaceLoss(scale=16), "epoch": 5, "optimizer": optimizer},
#   {"loss": losses.ArcfaceLoss(scale=32), "epoch": 5},
  {"loss": losses.ArcfaceLoss(scale=64), "epoch": 35},
  # {"loss": losses.ArcfaceLoss(), "epoch": 20, "triplet": 64, "alpha": 0.35},
]
tt.train(sch, 0)

It occurred a bug in train.py:

Traceback (most recent call last):
  File "fine-tuning-CelebA.py", line 2, in <module>
    import losses, train, models
  File "/home/cry/H6-K/Keras_insightface/train.py", line 381
    if not hasattr(cur_optimizer, "_variables") and hasattr(cur_optimizer, "_optimizer"), hasattr(cur_optimizer._optimizer, "_variables"):
                                                                                        ^
SyntaxError: invalid syntax

How to modify? Can I write as:

if not hasattr(cur_optimizer, "_variables") and hasattr(cur_optimizer, "_optimizer") and hasattr(cur_optimizer._optimizer, "_variables"):
@leondgarse
Copy link
Owner

Yes, you are right, and it's my fault.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants